akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=200010;
const ll mod=1e9+7;


int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  int maxi=-inf;
  int xi=-1;
  int mini=inf;
  int ni=-1;
  rep(i,n){
    cin >> a[i];
    if(a[i]>maxi){maxi = a[i]; xi=i; }
    if(a[i]<mini){mini = a[i]; ni=i; }
  }
  
  vector<P> ans;
  if(abs(maxi)>=abs(mini)){
    rep(i,n)if(a[i]<0){
      ans.emplace_back(xi+1,i+1);
    }
    for(int i=0; i<n-1; i++){
      ans.emplace_back(i+1,i+2);
    }
  } else {
    rep(i,n)if(a[i]>0){
      ans.emplace_back(ni+1,i+1);
    }
    for(int i=n-1; i>0; i--){
      ans.emplace_back(i+1,i);
    }
  }
  
  cout << ans.size() << endl;
  rep(i,ans.size()){
    cout<<ans[i].F<<" "<<ans[i].S<<" "<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
n,d=map(int,input().split())
x=[list(map(int,input().split())) for _ in range(n)]
p=0
def c(i,j):
  global x
  s=0
  for k in range(d):
    s+=(x[i][k]-x[j][k])**2
  if (s**(1/2)).is_integer()==True:
    return 1
  else:
    return 0
for i in range(n):
  for j in range(i+1,n):
    p+=c(i,j)
print(p)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
	cin.tie(NULL);
	cout.tie(NULL);
	int x;
	cin>>x;
	if(x>=30)
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3636
x = int(input())
n = 2 *(10 ** 5)
primes = set(range(2, n+1))
for i in range(2, int(n**0.5+1)):
    primes.difference_update(range(i*2, n+1, i))
primes = list(primes)
import bisect
b = bisect.bisect_right(primes, x)
if x == primes[b - 1]:
    print(x)
else:
    print(primes[b])

Measured memory_bytes: 21732
#include<bits/stdc++.h>
#define se second
#define fi first
using namespace std;
const int maxn = 2e3 + 4, mod = 11092019, maxx = 1e6 + 1;
typedef pair<int,int> ii;
typedef pair<long long, long long> ll;
int n, d[maxn], cnt[maxn]; 
vector<int> a[maxn];

void _accepted_by_one_hit_()
{
    #ifdef NTMA
        freopen("abc.inp", "r", stdin);
        freopen("abc.out", "w", stdout);
    #endif
    ios::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
}
void bfs(int x)
{
    for(int i=1; i<=n; ++i) d[i] = 0;
    queue<int> q; q.push(x);
    while (!q.empty()){
        int u = q.front(); q.pop();
        for(auto v: a[u]) {
            if (v == x || d[v]) continue;
            d[v] = d[u] + 1;
            q.push(v); 
        }
    }
    for(int i=x+1; i<=n; ++i) cnt[d[i]]++;
}
int main()
{
    _accepted_by_one_hit_();
    int x, y;
    cin >> n >> x >> y;
    for(int i=1; i<n; ++i) {
        a[i].push_back(i+1);
        a[i+1].push_back(i);
    }
    a[x].push_back(y);
    a[y].push_back(x);
    for(int i=1; i<=n; ++i) bfs(i);
    for(int i=1; i<n; ++i) cout << cnt[i] << '\n';
}

Measured memory_bytes: 384
#include<stdio.h>
#define MAX 100005
#define NIL -1
  
struct Node{ int p, l, r;};
struct Node T[MAX];
int n, H, D[MAX];
int getDepth(int);
void print(int);


  
int main(){
  int i, j, d, v, c,l,r;
    
  scanf("%d",&n);
    
  for ( i = 0; i < n; i++ ) {
    T[i].p = T[i].l = T[i].r = NIL;
  }
    
  for ( i = 0; i < n; i++ ){
    scanf("%d %d", &v, &d);
    for ( j = 0; j < d; j++ ){
      scanf("%d", &c);
      T[c].p = v;
        
      if(j == 0) T[v].l = c;
        
      else if (j >= 1)
	T[r].r = c;
      r = c;
    }
  }
    
  
  for ( i = 0; i < n; i++ ){
    D[i] = getDepth(i);
  }
  
  for ( i = 0; i < n; i++ ) print(i);
  return 0;
}


int getDepth(int u){
  int d = 0;
  
  while(T[u].p >= 0){
    u = T[u].p; 
    d++;
  }
  
  return d;
}
  
void print(int u){
  if(T[u].p == NIL)
    printf("node %d: parent = %d, depth = %d, root, ",u,T[u].p,D[u]);
    
  else if(T[u].l == NIL)
    printf("node %d: parent = %d, depth = %d, leaf, ",u,T[u].p,D[u]);
    
    
  else printf("node %d: parent = %d, depth = %d, internal node, ",u,T[u].p,D[u]);
    
    
  printf("[");
  int t; 
  t = u;
  if(T[t].l  != NIL){
    printf("%d",T[t].l);
    if(T[T[t].l].r == NIL)
      printf("]\n");
    else printf(",");
    t =T[t].l;
    while(T[t].r != NIL){
      printf(" %d",T[t].r);
  
      if(T[T[t].r].r == NIL)
	printf("]\n");
      else printf(",");
      t =T[t].r;
    }
  }
  else  printf("]\n");
}



Measured memory_bytes: 3276
#include<iostream>
#include<stdio.h>
#include<math.h>

int main(){
    char str[101];
    long long no,i;

    scanf("%s",str);
    scanf("%lld",&no);
    
    for(i = 0; i < no; i++){
        if(str[i] != '1'){
            printf("%c\n",str[i]);
            return 0;
        }
    }
    printf("1\n");
    
    return 0;
}

Measured memory_bytes: 256
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from itertools import permutations, combinations,combinations_with_replacement,product
from fractions import Fraction as frac
import bisect
import heapq

import logging
logging.basicConfig(level=logging.DEBUG)

import sys
#input = sys.stdin.readline().rstrip

setrecursionlimit(1000000)

MOD = 10**9+7
INF = float('inf')

def main():
    N=int(input())
    S=input()
    A='ABCDEFGHIJKLMNOPQRSTUVWXYZ'

    ans=[]
    for c in S:
        i=A.index(c)
        ans.append(A[(i+N)%26])
    print("".join(ans))
main()


Measured memory_bytes: 69740
/**
 *    author:  math2do
 *    created: 05.04.2020 14:04:51
**/

#include <bits/stdc++.h>

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector <int> arr(n);
  int sum = 0;
  for (int &val : arr) {
    cin >> val;
    sum += val;
  }
  int cnt = 0;
  bool found = false;
  for (int i = 0; i < n; i++) {
    if (4 * m * arr[i] >= sum) {
      cnt++;
    }
    if (cnt >= m) {
      found = true;
      goto end;
    }
  }
  end : {
    cout << (found ? "Yes" : "No") << endl;
  } 
  return 0;
}


Measured memory_bytes: 256
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> void get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'; t=getchar());
	if(t=='-')neg=true,t=getchar();
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) get1(a),get1(b)
#define get3(a,b,c) get1(a),get2(b,c)
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

char s[1000111],t[1000111];
int n,pre[1000111][26],ans;
#define move orzyjz
int h[1000111],move,delta;
int main()
{
	get1(n);scanf("%s%s",s+1,t+1);
	if(strcmp(s+1,t+1)==0)
	{
		puts("0");
		return 0;
	}
	for(int i=1;i<=n;i++)
	{
		memcpy(pre[i],pre[i-1],sizeof(pre[i]));
		pre[i][s[i]-'a']=i;
	}
	int last=n;
	for(int i=1;i<=n+1;i++)h[i]=1;
	for(int i=n;i>=1;i--)
	{
		if(t[i]==t[i-1])
		{
			if(i<=last)
			{
				for(int j=i;j<=last;j++)h[j+move]=1-delta;
				last=i-1;
			}
			ans=max(ans,h[i+move]+delta);
			continue;
		}
		ans=max(ans,i>=last?h[i+move+1]+delta:0);
		for(int j=pre[last][t[i]-'a'];j<=last;j++)h[j+move]=1-delta;
		h[i+move+1]=h[i+move]-1;
		move++;delta++;
		last=pre[last][t[i]-'a']-1;
	}
	if(last)ans=-1;
	printendl(ans);
	return 0;
}

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

int n, m;
std::vector<int> vec;
int l, r;
int main() {
    std::cin >> n >> m;
    vec.assign(n+2, 0);
    for (int i = 0; i < m; i++) {
        std::cin >> l >> r;
        vec[l]++;
        vec[r+1]--;
    }
    for (int i = 2; i <= n; i++) {
        vec[i] += vec[i-1];
    }
    std::cout << std::count(vec.begin(), vec.end(), m) << std::endl;
}

Measured memory_bytes: 640
#include<stdio.h>

void space(int A[], int N){
	int i;
	for(i=0;i<N;i++){
		if(i>0) printf(" ");
		printf("%d", A[i]);
	}
	printf("\n");
}

void insertionsort(int A[], int N){
	int i, j, v;
	for(i=1;i<N;i++){
		v=A[i];
		j=i-1;
		while(j>=0 && A[j]>v){
			A[j+1]=A[j];
			j--;
		}
		A[j+1]=v;
		space(A,N);
	}
}

int main(int argc, char const *argv[])
{
	int N, i, j;
	int A[100];

	scanf("%d",&N);
	for(i=0;i<N;i++) scanf("%d",&A[i]);

	space(A,N);
	insertionsort(A,N);
		
	return 0;
}


Measured memory_bytes: 2072
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#define ll long long
using namespace std;
const int mn = 55, ms = 2600;
ll a[mn], s[mn], f[mn][mn][ms];
int main()
{
	int n, m, i, j, k;
	scanf("%d%d", &n, &m);
	for(i = 1; i <= n; i++)
		scanf("%lld", &a[i]), s[i] = a[i] + s[i - 1];
	f[1][0][0] = f[1][1][a[1]] = 1;
	for(i = 2; i <= n; i++)
		for(j = 0; j <= i; j++)
			for(k = s[i]; k >= 0; k--)
			{
				f[i][j][k] += f[i - 1][j][k];
				if(j - 1 >= 0 && k >= a[i])
					f[i][j][k] += f[i - 1][j - 1][k - a[i]];
			}
	ll ans = 0;
	for(j = 1; j <= i; j++)
		for(k = 0; k <= s[n]; k++)
			if(k % j == 0 && k / j == m)
				ans += f[n][j][k];
	printf("%lld\n", ans);
}


Measured memory_bytes: 55424
#include<cstdio>
#include<cstring>
#include<cctype>
#include<cmath>
#include<algorithm>
#define ll long long
using namespace std;
int read(){
    char c;int s=0,t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
int min(int a,int b){return a<b?a:b;}
int max(int a,int b){return a<b?b:a;}
int abs(int x){return x>0?x:-x;}
void mins(int &a,int b){if(a>b)a=b;}
void maxs(int &a,int b){if(a<b)a=b;}
/*------------------------------------------------------------*/
const int inf=0x3f3f3f3f,maxn=100010;

int n,first[maxn],tot,A,B,m,b[maxn];
bool vis[maxn],ok;
struct edge{int v,from;}e[maxn*2];
void insert(int u,int v){tot++;e[tot].v=v;e[tot].from=first[u];first[u]=tot;}
void dfs(int x,int k,int fa){
	if(vis[x]){
		if(k!=b[x])ok=1;
	}else{
		vis[x]=1;b[x]=k;
		if(k)A++;else B++;
		for(int i=first[x];i;i=e[i].from)if(e[i].v!=fa){
			dfs(e[i].v,k^1,x);
		}
	}
}
int main(){
    n=read();m=read();
    for(int i=1;i<=m;i++){
    	int u=read(),v=read();
    	insert(u,v);insert(v,u);
    }
    dfs(1,0,0);
    ll ans=0;
    if(ok)ans=1ll*n*(n-1)/2-m;else{
    	ans=1ll*A*B-m;
    }
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin >> a >> b;
    if(a < b){
        for (int i = 0; i <b; i++)
        {
            cout << a;
        }
    }else{
        for (int i = 0; i < a; i++)
        {
            cout << b;
        }
    }
    cout << endl;
}

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

int main(){
    string s;
    cin >> s;
    while(1){
        s.pop_back();
       if(s.size()%2==0){
           int k = s.size()/2;
           for(int i=0;s[i]==s[k+i];i++){
                if(i==k-1){
                    cout << s.size() << endl;
                    return 0;
                }
           }
       }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <time.h>
#include <stdio.h>
#include <vector>
#define int long long
#define endre getchar();getchar();return 0
constexpr auto INF = 1000000007;
using namespace std;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int mypow(int x, int y) {
	if (y == 0)return 1;
	if (y % 2)return mypow(x, y - 1)*x;
	else return mypow(x, y / 2)*mypow(x, y / 2);
}
int Max(int x, int y) {
	if (x > y)return x;
	else return y;
}
int Min(int x, int y) {
	if (x < y)return x;
	else return y;
}
int kai(int x) {
	int cnt = 1;
	if (x == 0)return 1;
	cnt = kai(x - 1);
	return x * cnt;
}
int prime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
/*Library End!*/
int a[15], ans = INF;
signed main() {
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		a[i] = (int)s[i] - '0';
	}
	for (int i = 0; i < s.size() - 2; i++) {
		int memo = a[i] * 100 + a[i + 1] * 10 + a[i + 2];
		ans = min(ans, abs(753 - memo));
	}
	cout << ans << endl;
	endre;
}


Measured memory_bytes: 256
// #pragma GCC optimize ("O3")
// #pragma GCC target ("sse4")

#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 29;
const int NINF = -1*INF;
const long long LLINF = 1ll << 60;
const long long LLNINF = -1*LLINF;

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
	return os << "[ " << p.first << ", " << p.second << "]" ;
}

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
typedef vector<vll> vvll;
typedef vector<vd> vvd;
typedef vector<vld> vvld;
 
#define mp make_pair
#define pb push_back
#define pf push_front
#define all(x) x.begin(), x.end()
#define revAll(x) x.rbegin(), x.rend()
#define gcd(a, b) __gcd(a, b)
#define popcount(x) __builtin_popcount(x)
#define isize(x) (int)(x.size())
#define rep(i,n) for(int i = 0; i < n; i++)
#define umap unordered_map
#define uset unordered_set
#define pq priority_queue

const ll MOD = 1e9 + 7;

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);
	int x; cin >> x;
	cout << (x == 1 ? "0" : "1");
}

Measured memory_bytes: 3668
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>
//#include<bits/stdc++.h>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;++i)
#define REP(i,s,n) for(int i=(s);i<(n);++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define REPR(i,s,n) for(int i=(s);i>=(n);--(i))
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
typedef vector<P> vP;
const ll mod = 1e9 + 7;
ll dx[4] = { 1,0,-1,0 };
ll dy[4] = { 0,1,0,-1 };

void printvll(vll v) {
	cout << "------------------------------------------------\n";
	rep(i, v.size()) cout << v[i] << " ";
	cout << endl;
	cout << "------------------------------------------------\n";
}
void printvvll(vvll v) {
	cout << "------------------------------------------------\n";
	rep(i, v.size()) {
		rep(j, v[i].size()) {
			cout << v[i][j] << " ";
		}
		cout << endl;
	}
	cout << "------------------------------------------------\n";
}

void prints(string s) {
	cout << "------------------------------------------------\n";
	rep(i, s.size()) cout << s[i] << " ";
	cout << endl;
	cout << "------------------------------------------------\n";
}

void printvs(vs s) {
	cout << "------------------------------------------------\n";
	rep(i, s.size()) {
		rep(j, s[i].size()) {
			cout << s[i][j] << " ";
		}
		cout << endl;
	}
	cout << "------------------------------------------------\n";
}

void Yes(bool x) {
	if (x) cout << "Yes\n";
	else cout << "No\n";
}

void YES(bool x) {
	if (x) cout << "YES\n";
	else cout << "NO\n";
}

void yes(bool x) {
	if (x) cout << "yes\n";
	else cout << "no\n";
}

uintmax_t combination(unsigned int n, unsigned int r) {
	if (r * 2 > n) r = n - r;
	uintmax_t dividend = 1;
	uintmax_t divisor = 1;
	for (unsigned int i = 1; i <= r; ++i) {
		dividend *= (n - i + 1);
		divisor *= i;
	}
	return dividend / divisor;
}

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

	ll  d, n, r ,l ,k, ans = 0, ret = M;
	bool flag = false, flag2 = false;
	string s, t;
	char c;
	cin >> s;
	t = "ACGT";
	ll cnt = 0;
	rep(i, s.size()) {
		bool x = false;
		rep(j, 4) {
			if (s[i] == t[j]) x = true;
		}
		if (x) cnt++;
		else {
			ans = max(ans, cnt);
			cnt = 0;
		}
	}
	ans = max(ans, cnt);
	cnt = 0;
	cout << ans << endl;
	return 0;

}


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

public class Main{
    static Utility.FastReader fr=new Utility.FastReader();
    static PrintWriter out=new PrintWriter(System.out);

    public static void main(String[] args){
        int t=1;
        while(t-->0){
            String s=fr.nextLine();
            if(s.charAt(s.length()-1)=='s')
                System.out.println(s.substring(0, s.length())+"es");
            else
                System.out.println(s+"s");
        }
        out.close();
    }


    static void debug(Object... o){
        System.err.println(Arrays.deepToString(o));
    }

    static class Utility{
        static void sort(int[] a){
            ArrayList<Integer> list=new ArrayList<>();
            for(int i: a) list.add(i);
            Collections.sort(list);
            for(int i=0;i<a.length;i++) a[i]=list.get(i);
        }

        static void shuffleArray(long[] arr){
            int n=arr.length;
            Random rnd=new Random();
            for(int i=0;i<n;++i){
                long tmp=arr[i];
                int randomPos=i+rnd.nextInt(n-i);
                arr[i]=arr[randomPos];
                arr[randomPos]=tmp;
            }
        }

        static void shuffleArray(int[] arr){
            int n=arr.length;
            Random rnd=new Random();
            for(int i=0;i<n;++i){
                int tmp=arr[i];
                int randomPos=i+rnd.nextInt(n-i);
                arr[i]=arr[randomPos];
                arr[randomPos]=tmp;
            }
        }

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

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

        static class FastReader{
            BufferedReader br;
            StringTokenizer st;

            public FastReader(){
                br=new BufferedReader(new
                        InputStreamReader(System.in));
            }

            String next(){
                while(st==null||!st.hasMoreElements()){
                    try{
                        st=new StringTokenizer(br.readLine());
                    }catch(IOException e){
                        e.printStackTrace();
                    }
                }
                return st.nextToken();
            }

            int nextInt(){
                return Integer.parseInt(next());
            }

            long nextLong(){
                return Long.parseLong(next());
            }

            double nextDouble(){
                return Double.parseDouble(next());
            }

            String nextLine(){
                String str="";
                try{
                    str=br.readLine();
                }catch(IOException e){
                    e.printStackTrace();
                }
                return str;
            }
        }
    }
}



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

int main() {
    int n, m, c;
    cin >> n >> m >> c;
    vector<int> b(m);
    rep(i, m) cin >> b[i];
    vector<vector<int>> a(n, vector<int>(m));
    rep(i, n) rep(j, m) cin >> a[i][j];
    int count = 0;
    rep(i, n) {
        int sum = 0;
        rep(j, m) {
            sum += a[i][j] * b[j];
        }
        sum += c;
        if (sum > 0)
        {
            count += 1;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>
#define p(x) puts(x)
char m[9][9];
int i,j;
int main()
{
	for(i=0;i<9;i++)
		gets(m[i]);
	p("90");
	for(i=0;i<8;i++,p(""))
		for(j=7;j>=0;j--)
			putchar(m[j][i]);
	p("180");
	for(i=7;i>=0;i--,p(""))
		for(j=7;j>=0;j--)
			putchar(m[i][j]);
	p("270");
	for(i=7;i>=0;i--,p(""))
		for(j=0;j<8;j++)
			putchar(m[j][i]);
	return 0;
}

Measured memory_bytes: 524
S = input()
T = input()
dict_st = {}
dict_ts = {}
N = len(S)
for i in range(N):
    if S[i] not in dict_st:
        dict_st[S[i]] = T[i]
    else:
        if dict_st[S[i]] != T[i]:
            print("No")
            exit()
for i in range(N):
    if T[i] not in dict_ts:
        dict_ts[T[i]] = S[i]
    else:
        if dict_ts[T[i]] != S[i]:
            print("No")
            exit()
print("Yes")

Measured memory_bytes: 3632
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define mod  1073741824
using namespace std;
int main()
{
  	int n;
    string s,s1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    cin >> n >> s;
    for (int i = 0; i < s.size(); ++i)
    {
        int k = -1; 
        for (int j = 0; j < s1.size(); ++j)
        {
            if (s[i] == s1[j])
            {
                k = j;
            }
        }
        int m = (k+n) % 26;
        s[i] = s1[m];
    }
    cout << s;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int a[4];
int n;
void init()
{
    a[0]=n/1000;
    a[1]=(n-1000*a[0])/100;
    a[2]=(n-1000*a[0]-100*a[1])/10;
    a[3]=n%10;
}
int main()
{
    while(cin>>n){
        init();
        if(a[0]+a[1]+a[2]+a[3]==7){
            cout<<a[0]<<"+"<<a[1]<<"+"<<a[2]<<"+"<<a[3]<<"=7"<<endl;
            continue;
        }
        else if(a[0]-a[1]+a[2]+a[3]==7){
            cout<<a[0]<<"-"<<a[1]<<"+"<<a[2]<<"+"<<a[3]<<"=7"<<endl;
            continue;
        }
        else if(a[0]+a[1]-a[2]+a[3]==7){
            cout<<a[0]<<"+"<<a[1]<<"-"<<a[2]<<"+"<<a[3]<<"=7"<<endl;
        }
        else if(a[0]+a[1]+a[2]-a[3]==7){
            cout<<a[0]<<"+"<<a[1]<<"+"<<a[2]<<"-"<<a[3]<<"=7"<<endl;
            continue;
        }
        else if(a[0]-a[1]-a[2]+a[3]==7){
            cout<<a[0]<<"-"<<a[1]<<"-"<<a[2]<<"+"<<a[3]<<"=7"<<endl;
            continue;
        }
        else if(a[0]-a[1]+a[2]-a[3]==7){
            cout<<a[0]<<"-"<<a[1]<<"+"<<a[2]<<"-"<<a[3]<<"=7"<<endl;
            continue;
        }
        else if(a[0]+a[1]-a[2]-a[3]==7){
            cout<<a[0]<<"+"<<a[1]<<"-"<<a[2]<<"-"<<a[3]<<"=7"<<endl;
            continue;
        }
        else if(a[0]-a[1]-a[2]-a[3]==7){
            cout<<a[0]<<"-"<<a[1]<<"-"<<a[2]<<"-"<<a[3]<<"=7"<<endl;
            continue;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
#define fo(i,s,e) for (int i=(s); i < (e); i++)
#define all(obj) (obj).begin(), (obj).end()
/*卍卍卍 #define int long long 卍卍卍*/
signed main () {
  int n;cin >> n;
  vector<int> v(n,0);
  rep(i,n) cin>>v[i];
  int ans=0;
  int temp=0;
  rep(i,n-1){
    if(v[i]>=v[i+1]) temp+=1;
    else temp=0;
    ans=max(ans,temp);
  }
  cout << ans << endl;
}

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

int main(void) {
    int a[3], b[3];
    for (int i = 0; i < 3; i++) cin >> a[i] >> b[i];

    int cnt[4] = { 0 };
    for (int i = 0; i < 4; i++) {
        cnt[a[i]]++;
        cnt[b[i]]++;
    }
    sort(cnt, cnt+4);
    if ((cnt[0] == 1) && (cnt[1] == 2) && (cnt[2] == 2) && (cnt[3] == 2)) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<assert.h>
#define MIN(a,b) a<b?a:b
#define MAX(a,b) a>b?a:b
#define rep(i,a,b) for(i=a;i<b;i++)
#define rev(i,a,b) for(i=a;i>b;i--)
#define sf(a) scanf("%d",&(a))
#define pf(a) printf("%d",(a))
#define sfll(a) scanf("%lld",&(a))
#define pfll(a) printf("%lld",(a))
#define ssf(a) scanf("%s",(a))
#define spf(a) printf("%s",(a))
#define spc printf(" ");
#define nl printf("\n")
#define play int main()
#define out return
typedef int I;
typedef long long LL;
typedef char S;
typedef float F;
typedef double D;
int cmp(const void *a,const void *b)
{
    return (*(int*)a-*(int*)b);
}
play
{
    I a,b,i;
    sf(a),sf(b);
    rep(i,b-a+1,b)
    pf(i),spc;
    pf(b),spc;
    rep(i,b+1,b+a)
    pf(i),spc;
    nl;
    out 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }

int main(){
    int N, A, B;
    cin >> N >> A >> B;
    cout << min(B, A * N) << endl;
}

Measured memory_bytes: 256
import scala.io.Source.stdin

object Main extends App {
  def f(x:Double) = if(x == -0.0) 0.0 else x

  val results = stdin.getLines.map { s=>
    val n = s.split(",").map(_.toDouble)
    val d = Math.pow(n(2)-n(0),2) + Math.pow(n(3)-n(1),2)
    val inner = (n(2)-n(0))*(n(4)-n(0)) + (n(3)-n(1))*(n(5)-n(1))
    val (x,y) = (2*inner*(n(2)-n(0))/d + 2*n(0)-n(4), 2*inner*(n(3)-n(1))/d + 2*n(1)-n(5))
    "%.6f %.6f".format(f(x),f(y))
  }
  println(results.mkString("\n"))
}

Measured memory_bytes: 44144
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    int A, B;
    cin >> A >> B;
    for (int i = 0; i < 100000; i++){
        if (int(i * 0.08) == A && int(i * 0.1) == B){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;

}


Measured memory_bytes: 384
#include<map>
#include<set>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<ctime>
#include<vector>
#include<bitset>
#include<string>
#include<cstdio>
#include<numeric>
#include<utility>
#include<sstream>
#include<cstdlib>
#include<iomanip>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<functional>
#include<unordered_map>
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rv(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
#define pb(n) push_back(n)
#define ue(N) N.erase(unique(N.begin(),N.end()),N.end());
#define nou(S) cout << S
#define hou(S) cout << setprecision(30) << S << endl
#define vec(K,L,N,S) vector<L> K(N,S)
#define dv(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define tv(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define maxx 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
typedef long long int lli;
typedef unsigned long long int uli;
using namespace std;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  
  int n,k,sum=0;
  cin>>n>>k;
  ou(n-k+1);
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;

double dist(double x1, double y1, double x2, double y2);

int main(void){
    int n;
    cin>>n;
    double xa,ya,ra,xb,yb,rb;
    double d;
    for(int i=0;i<n;i++){
        cin>>xa>>ya>>ra>>xb>>yb>>rb;
        d=dist(xa,ya,xb,yb);
        if(d>ra+rb){
            cout<<0<<endl;
        }
        else if(d+rb<ra){
            cout<<2<<endl;
        }
        else if(d+ra<rb){
            cout<<-2<<endl;
        }
        else{
            cout<<1<<endl;
        }
    }
    return 0;
}

double dist(double x1, double y1, double x2, double y2){
    return sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
}



Measured memory_bytes: 3164
using System;

public class Hello
{
    public static void Main()
    {
        var imax = (int)(6 / Math.Log10(2)) + 1;
        var jmax = (int)(6 / Math.Log10(3)) + 1;
        var kmax = (int)(6 / Math.Log10(5)) + 1;
        int a; int b;
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            a = int.Parse(line[0]);
            if (a == 0) break;
            else b = int.Parse(line[1]);
            var count = 0;
            for (int i = 0; i <= imax; i++)
                for (int j = 0; j <= jmax; j++)
                    for (int k = 0; k <= kmax; k++)
                    {
                        var w = Math.Pow(2, i) * Math.Pow(3, j) * Math.Pow(5, k);
                        if (w >= a && w <= b) count++;
                    }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 9388
#include <stdio.h>

int main(void)
{
	int n;
	int ball;
	int b, c;
	int i, j;


	scanf("%d", &n);

	for (i = 0; i < n; i++) {
		b = c = 0;
		for (j = 0; j < 10; j++) {
			scanf("%d", &ball);
			if (b < ball && c < ball) {
				if (b > c) b = ball;
				else c = ball;
			}
			else if (b < ball) {
				b = ball;
			}
			else if (c < ball) {
				c = ball;
			}
			else {
				b = c = 100;
			}
		}

		if (b == 100) {
			printf("NO\n");
		} else {
			printf("YES\n");
		}
	}

	return (0);
}

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

using namespace std;

int main() {
	int n;
	cin >> n;
	if(n % 10 == 7 || n / 10 % 10 == 7 || n / 100 % 10 == 7) {
		puts("Yes");
	} else {
		puts("No");
	}
	return 0;
}

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

int main () {
  int n, a, b;
  cin >> n >> a >> b;
  string s;
  cin >> s;
  
  int counter = 0;
  int foreignerRank = 0;
  for (int i = 0; i < n; i++) {
    int contestant = s[i];
    if (contestant == 'a') {
      if (counter < a + b) {
        cout << "Yes" << endl;
        counter++;
      }
      else
        cout << "No" << endl;
    }
    
    else if (contestant == 'b') {
        foreignerRank++;
        if ((counter < a + b) && (foreignerRank <= b)) {
          cout << "Yes" << endl;
          counter++;
        }
        else
          cout << "No" << endl;
    }
    
    else
      cout << "No" << endl;
  }
}

Measured memory_bytes: 896
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <complex>
#define REP(i,a) for(int i=0;i<(a);i++)
#define REPR(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define FORE(i,a,b) for(int i=(a);i<=(b);i++)
#define ALL(a) a.begin(), a.end()
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<long long>;
using vvl = vector<vl>;
using vs = vector<string>;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

int main() {
  int A=si(), B=si(), C=si();
  if (A==B && B==C) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>


int main(void){
    int i,n,x,y,sq[15][15];
	
    while(scanf("%d",&n)){
        if(n==0)break;
		
        for(i=0, x=n/2, y=n/2-1; i < n*n; i++){
            if(i%n == 0) y += 2;
            else {
				y++;
				x++;
			}
            y = y%n;
			x = x%n;
            sq[y][x]=i+1;
        }
        for(y=0; y < n; y++){
            for(x=0; x < n; x++){
                printf("%4d",sq[y][x]);
            }
            printf("\n");
        }
    }
    return 0;
}

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

typedef long long int ll;
typedef long double ld;

//****************************************************                
#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define rlp(var,start,end) for(ll var = start; var>=end ; var--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll,ll> 
#define vpll vector<pll>
#define all(X) X.begin(),X.end()
#define endl "\n" //comment it for interactive questions
#define trace1(a) cerr << #a << ": " << a << endl;
#define trace2(a,b) cerr << #a << ": " << a << " " << #b << ": " << b << endl;
#define trace3(a,b,c) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << endl;
#define trace4(a,b,c,d) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << #d << ": " << d << endl;
#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
        //*******************************************************
//Some Functions

const ll MOD = (ll)1e9+7; //change it for other mods

ll powmod(ll a,ll b)
{
   ll res = 1;
   while(b > 0) {
      if(b & 1) res = (res * a) % MOD;
      a = (a*a)%MOD;
      b = b >> 1; 
  }
  return res % MOD;
}

void solve(ll testnum)
{
    ll n,k;
    cin >> n >> k;
    vll p(n), c(n);
    for(ll i=0;i<n;i++) {
    	cin >> p[i];
    }
    for(ll i=0;i<n;i++) {
    	cin >> c[i];
    }
    ll inf = (ll)1e18;
    ll ans = -inf;
    for(ll i=0;i<n;i++) {
    	vll tempvals;
    	vll vis(n, 0);
    	ll go = p[i] - 1;
    	ll tmp = -inf;
    	while(vis[go] == 0) {
    		tempvals.pb(c[go]);
    		vis[go] = 1;
    		go = p[go] - 1;
    	}
    	for(ll j=0; j < (ll)tempvals.size(); j++) {
    		if(j > 0) tempvals[j] += tempvals[j-1];
    		if(j < k) {
    			tmp = max(tmp, tempvals[j]);
    		}
    	}
    	ll nnt = (ll)tempvals.size();
	  	ll nrounds = k/nnt;
	  	ll lft = k % nnt;
	  	ll meowans = tempvals[nnt-1]*nrounds;
	  	ll meowans2 = -inf;
	  	if(nrounds > 0) {
	  		meowans2 = 0;
	  	}
	  	for(ll j=0; j<lft;j++) {
	  		meowans2 = max(meowans2, tempvals[j]);
	  	}
	  	if(nrounds > 0)ans = max(ans, tmp + tempvals[nnt-1]*(nrounds-1));
	  	// cout << lft << " " << i << " " << meowans << " " << meowans2 << "\n";
	  	meowans += meowans2;
	  	ans = max(ans, meowans);
	  	ans = max(ans, tmp);
    }
    cout << ans << "\n";
}

int main()
{
    FAST_IO;
    #ifdef STIO 
      freopen("input.txt" , "r", stdin);
      freopen("output.txt" , "w", stdout);
    #endif
    ll t = 1;
    // cin >> t;
    for (ll i = 1; i <= t; i++) {
        // cout << "Case #" << i << ": ";
        solve(i);
    }
}

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

int main() {
  int n,m;
  cin >> n >> m;
  vector<int> l(m),r(m);
  for(int i=0;i<m;i++)
    cin >> l.at(i) >> r.at(i);
  
  sort(l.begin(),l.end());
  sort(r.begin(),r.end());
  
  int c;
  c = r.at(0) - l.at(m-1) + 1;
  if(c<0)	c=0;
  
  cout << c << endl;
  
  return 0;
}


Measured memory_bytes: 4040
#include"bits/stdc++.h"

int main()
{
    std::map<std::string, int> map;
    map["SUN"] = 7;
    map["MON"] = 6;
    map["TUE"] = 5;
    map["WED"] = 4;
    map["THU"] = 3;
    map["FRI"] = 2;
    map["SAT"] = 1;
    std::string str;
    std::cin>>str;
    std::cout<<map[str]<<std::endl;
}

Measured memory_bytes: 256
#include <iostream>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

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

    string str;
    cin >> str;

    int indexA, indexZ;
    indexA = str.find('A');
    REP(i, str.size()) {
        if (str[i] == 'Z')
            indexZ = i;
    }

    cout << indexZ - indexA + 1 << '\n';
    return 0;
}

Measured memory_bytes: 720
from copy import deepcopy

N = int(input())
X = list(map(int,input().split()))
Y = deepcopy(X)
Y.sort()
med1 = Y[N//2-1]
med2 = Y[N//2]
##print("med1:",med1,"med2",med2)
for i in range(N):
    if X[i] > med1:
        print(med1)
    else:
        print(med2)

Measured memory_bytes: 26528
#include <iostream>
#include <vector>
#include <utility>
#include <queue>
#include <map>
#include <cmath>
#include <string>
using namespace std;

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

int main(){
    string s,t;
    int q;
    cin >> q;
    rep(zz,q){
        cin >> s >> t;
        int n = s.size();
        bool ok = 1;
        bool flag = 0;
        bool sflag = 0;
        bool tflag = 0;
        int sr = 0;
        int ssr = 0;
        int tr = 0;
        int out = 0;
        rep(i,n){
            if(s[i]!=t[i]&&ok){
                out = i;
                ok = 0;
                if(s[i]=='1'){
                    flag = 1;
                }
            }else if(!ok){
                if(s[i]!='0'){
                    sflag = 1;
                    sr = i;
                }
                if(t[i]!='0'){
                    tflag = 1;
                    tr = i;
                }
            }
        }
        //cout << out << endl;
        rep(i,out){
            if(s[i]!='0'){
                ssr = i;
            }
        }
        // cout << ssr << endl;
        // cout << flag << " " << sflag << " " << tflag << endl;
        if(ok){
            cout << 0 << endl;
            continue;
        }
        int ans = 0;
        if(flag){
            if(sflag&tflag){
                ans += sr-out;
                ans += tr-out;
            }else if(sflag&(!tflag)){
                ans += sr-ssr;
            }else if((!sflag)&tflag){
                ans += tr-out;
            }else{
                ans = out-ssr;
            }
        }else{
            if(sflag&tflag){
                ans += sr-out;
                ans += tr-out;
            }else if(sflag&(!tflag)){
                ans += sr-out;
            }else if((!sflag)&tflag){
                ans += tr-ssr;
            }else{
                ans += out-ssr;
            }
        }
        cout << ans << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3220
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define IO ios::sync_with_stdio(false), cin.tie(0)
#define endl '\n'
#define main() int main()
#define ff1(i,n) for(int i=1;i<=n;++i)
#define ff0(i,n) for(int i=0;i<n;++i)
#define pi acos(-1.0)
#define ms(a, x) memset(a, x, sizeof(a))
#define lowbit(x) ((x)&(-(x)))
#define pb push_back
#define binarycount __builtin_popcount(x)
#define tr t[root]
#define lson t[root << 1]
#define rson t[root << 1 | 1]
#define fir first
#define sec second
#define debug(x) cout<<x<<'\n'
#define sa(a) scanf("%d", &a)
#define sab(a, b) scanf("%d%d", &a, &b)
#define pa(a) printf("%d",a)
#define pab(a,b) printf("%d%d",a,b)
#define pii pair<string,int>
using namespace std;

#define maxn 100010
const int inf = 0x3f3f3f3f;
const int mod = 9973;
const double eps = 1e-8;
ll gcd(ll a, ll b) {return b==0?a:gcd(b, a%b);}
ll lcm(ll a, ll b) {return a/gcd(a, b)*b;}
int max(int x,int y){if(x>y) return x;return y;}
ll powmod(ll a,ll b){
    ull ans = 1, pow = a%mod;
    while(b) { if(b&1) ans = (ans*pow)%mod; pow = (pow*pow)%mod; b >>= 1; }
    return ans%mod;
}
main(){
	IO;
    int n;
	cin>>n;
	vector<int> a(n+1);
	ff1(i,n) cin>>a[i];
	int dp[n+1]={0};
	dp[1]=0;dp[2]=abs(a[2]-a[1]);
	for(int i=3;i<=n;i++){
		dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
	}
	cout<<dp[n]<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
typedef long long ll;
ll MOD=1e9+7;
using namespace std;

int main() {
    int n, alpha[26]={0};
    string s;
    cin >> n >> s;
    for(int i=0; i<n; i++) alpha[s[i]-'a']++;
    ll ans = 1;
    for(int i=0; i<26; i++) ans = (ans*(alpha[i]+1))%MOD;
    cout << ans-1 << endl;
    return 0;
}


Measured memory_bytes: 512
from bisect import *
a=[]
b=[]
n=int(input())
for i in range(n):
    g=float(input())
    a.append(g)
    insort_left(b,g)
for i in range(n):
    win=bisect_left(b,a[i])
    lose=n-bisect_right(b,a[i])
    print(3*win+(n-win-lose-1))


Measured memory_bytes: 9480
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define x first
#define y second

char x[500'100];
int nx;
int y[500'100];
int z[500'100];
int ny;

void in(){
    scanf("%s", x);
	reverse(x, x+strlen(x));
	for(nx=0; x[nx]; ++nx) x[nx]-='0';
}

void m9(){
    for(int i=0; i<nx; ++i) y[i]=x[i]*9;
    for(int i=0; i<=nx; ++i){
        y[i+1] += y[i]/10; y[i]%=10;
    }
    for(int i=0; i<=nx+2; ++i) if(y[i]) ny=i+1;
}

int start[500'010];
int term[500'010];
vector<int> inc;

int main()
{
	in();
	m9();
	ll need = 1;
	ll pt = 1;
	for(int i=0; i<7; ++i){
		need += pt*(9-y[i]);
		start[i]=need;
		pt *= 10;
		term[i]=pt;
	}
	for(int i=7; i<ny; ++i){
		if(y[i]!=9 && i>=16) break;
		need += pt*(9-y[i]);
		if(need > 500'0000) break;
		inc.pb(need);
		pt *= 10;
	}
	int ii=0;
	int dsum = accumulate(y, y+ny, 0);
	for(int k=1; k<=500'0000; ++k){
		while(ii < int(inc.size()) && inc[ii]==k){
			++ii; dsum -= 9;
		}
		int cd = dsum;
		for(int i=0; i<7; ++i){
			if(k >= start[i])
				cd -= (k+term[i]-start[i])/term[i]*9;
		}
		if(cd <= 0){
			printf("%d\n", (k+8)/9);
			break;
		}
	}
    return 0;
}


Measured memory_bytes: 8692
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

signed main()
{
    int n,x;
    cin>>n>>x;
   if(x==1 || x==2*n-1){
       cout<<"No"<<endl;
   }
   else{
       cout<<"Yes"<<endl;
       int cnt=0;
       int i=2;
       vector<int>a(2*n);
       while(cnt<n-2){
           if(i==x) {
               i++;
               continue;
           }
           //cout<<i<<endl;
           a[cnt]=i;
           i++;
           cnt++;
       }
       cnt+=3;
       while(cnt<2*n-1){
           
           if(i==x){
               i++;
               continue;
           }
           //cout<<i<<endl;
           a[cnt]=i;
           i++;
           cnt++;
       }
        for (int i = 0; i < n-2; i++)
        {
            cout<<a[n+1+i]<<endl;
        }
        cout<<1<<endl;
        cout<<x<<endl;
        cout<<2*n-1<<endl;
        for (int i = 0; i < n - 2; i++)
        {
            cout << a[i] << endl;
        }
   }
    return 0;
}

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

int main()
{
   long long int n,m;
   cin>>n>>m;
    int x,sum=0;
   for(int i=0;i<m;i++)
    {
       cin>>x;
        sum=sum+x;
    }    
   
     if(sum>n)
      {
          cout<<"-1"<<endl;
      }
      else
       {
           cout<<n-sum;
       }

}


Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>

using namespace std;

int main()
{
    long long N, SN;
    cin >> N;
    SN = N;

    int sum = 0;
    int a = 0;

    while (N != 0)
    {
        a = N % 10;
        sum += a;
        N /= 10;
    }

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

    return 0;
}


Measured memory_bytes: 888
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<vector>
using namespace std;
const int maxn=1e5+7;
bool vis[maxn];
bool check(int x){
	while(x){
		if(vis[x%10]) return false;
		x=x/10;
	}
	return true;
}
int main(){
	int n,k,x;
	cin>>n>>k;
	for(int i=1;i<=k;i++){
		cin>>x;
		vis[x]=1;
	}
	for(int i=n;;i++){
		if(check(i)){
			cout<<i<<endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256