akhauriyash/Code-Regression huggingface dataset:
#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>
#include <bitset>
#include <atcoder/all>

using namespace std;
using namespace atcoder;

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, m;
    cin >> n >> m;
    scc_graph g(n);
    while(m--) {
        ll a, b;
        cin >> a >> b;
        g.add_edge(a, b);
    }
    auto ans = g.scc();
    cout << ans.size() << endl;
    for(auto& i : ans) {
        cout << i.size() << ' ';
        for(auto& j : i) cout << j << ' ';
        cout << endl;
    }
    return;
}

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

Measured memory_bytes: 40592
eval"N,K,*A="+`dd`.split*?,
s=eval A*?+
1.upto(3e4){|j|s%j<1&&$*<<j<<s/j}
p$*.reject{|h|t=0
A.map{|x|x%h}.sort.count{|x|K<t+=x}>t/h}.max

Measured memory_bytes: 12416
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

typedef long long ll;
using namespace std;
#define mod 1000000007

int main(){
    ll n,m;cin >> n >> m;
    vector<ll>a(m+3);
    for(ll i=0;i<m;i++){
        cin >> a[i];
    }
    vector<ll>f(n+1);
    f[0]=1;
    f[1]=1;
    ll next=0;
    if(a[0]==1){
        f[1]=0;
        if(next<m-1)next++;
    }
    for(ll i=2;i<=n;i++){
        f[i]=f[i-1]+f[i-2];
        if(a[next]==i && next<=m-1){
            f[i]=0;
            if(next<m-1)next++;
        }
        f[i]%=mod;
    }
    cout << f[n] << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
struct rest{
	string n;
	int s;
	int ind;
};
bool sortByName;
rest tArr[101];
void mergeArr(rest arr[], int left, int right, int mid){
	for(int i=left; i<=right; i++){
		tArr[i]=arr[i];
	}
	int i=left, j=mid+1;
	int k=left;
	while(i<=mid && j<=right){
		if(sortByName){
			if(tArr[i].n<tArr[j].n){
				arr[k++]=tArr[i++];
			}
			else{
				arr[k++]=tArr[j++];
			}
		}
		else{
			if(tArr[i].s>tArr[j].s){
				arr[k++]=tArr[i++];
			}
			else{
				arr[k++]=tArr[j++];
			}
		}
	}
	while(i<=mid){
		arr[k++]=tArr[i++];
	}
	while(j<=right){
		arr[k++]=tArr[j++];
	}
}

void mergeSort(rest arr[], int left, int right){
	if(left<right){
		int mid=left+(right-left)/2;
		mergeSort(arr, left, mid);
		mergeSort(arr, mid+1, right);
		mergeArr(arr, left, right, mid);
	}
}
int main(){
	int n, i;
	rest restaurants[101];
	cin >> n;
	for(i=0; i<n; i++){
		cin >> restaurants[i].n >> restaurants[i].s;
		restaurants[i].ind=i;
	}
	//sort(restaurants, restaurants+n, sortByName);
	sortByName=true;
	mergeSort(restaurants, 0, n-1);
	sortByName=false;
	int lInd=0;
	for(i=1; i<n; i++){
		if(restaurants[i].n!=restaurants[lInd].n){
			mergeSort(restaurants, lInd, i-1);
			//sort(restaurants+lInd, restaurants+i-1, sortByScore);
			lInd=i;
		}
	}
	mergeSort(restaurants, lInd, i-1);
	//sort(restaurants+lInd, restaurants+i-1, sortByScore);
	for(i=0; i<n; i++){
		cout << restaurants[i].ind+1 << "\n";
	}
}


Measured memory_bytes: 256
s = input()
s = s[0:-1]
for i in range(len(s)):
    for j in range(len(s)//2):
        if len(s)%2 ==1:
            s = s[0:-1]
            break
        elif s[j] != s[len(s)//2+j]:
            s= s[0:-1]
            break
print(len(s))

Measured memory_bytes: 3060
def countRowColumn(color):
    blackr = []
    for i in range(row):
        blackr.append(color[i].count('#'))
    blackc = []
    for i in range(col):
        c = 0
        for j in range(row):
            if color[j][i]=='#':
                c+=1
        blackc.append(c)
    
def counting(color):
    t=0
    for c in color:
        t+=c.count('#')
    return t
def func(color,setr,setc,r,c):
    counts = counting(color)
    if counts<k:
        return 0
    if counts==k:
        dp.add((tuple(sorted(setr)),tuple(sorted(setc))))
    #if r==row or c==col:
    #    return 0
    for i in range(r,row):
        temp = []
        for j in range(col):
            temp+=[color[i][j]]
            color[i][j]='R'
        setr.add(i)
        func(color,setr,setc,i+1,c)
        setr.remove(i)
        for j in range(col):
            color[i][j]=temp[j]
    for j in range(c,col):
        temp = []
        for i in range(row):
            temp+=[color[i][j]]
            color[i][j]='R'
        setc.add(j)
        func(color,setr,setc,r,j+1)
        setc.remove(j)
        for i in range(row):
            color[i][j]=temp[i]
    return 0
    
dp = set()
row, col, k = map(int,input().split())
color = []
blackr = []
for _ in range(row):
    color.append(list(input()))
    blackr.append(color[-1].count('#'))
blackc = []
for i in range(col):
    c = 0
    for j in range(row):
        #print(j,i)
        if color[j][i]=='#':
            c+=1
    blackc.append(c)
total = sum(blackr)
#print(total)
if total<k:
    print(0)
else:
    func(color,set(),set(),0,0)
    print(len(dp))

Measured memory_bytes: 71836
#include <bits/stdc++.h>
using namespace std;
int n, k;
int a[55];

bool cmp(int x, int y) { return x > y; }

int main() {
	scanf("%d %d", &n, &k);
	for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
	sort(a + 1, a + n + 1, cmp);
	int sum = 0;
	for(int i = 1; i <= k; i++) sum += a[i];
	printf("%d\n", sum);
}

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

#define si(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define sd(a) scanf("%lf",&a)
#define sc(a) scanf("%c",&a)
#define ss(a) scanf("%s",a)
#define pi(a) printf("%d\n",a)
#define pl(a) printf("%lld\n",a)
#define pc(a) putchar(a)
#define ms(a) memset(a,0,sizeof(a))
#define repi(i, a, b) for(register int i=a;i<=b;++i)
#define repd(i, a, b) for(register int i=a;i>=b;--i)
#define reps(s) for(register int i=head[s];i;i=Next[i])
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define pii pair<int,int>
#define mii unordered_map<int,int>
#define msi unordered_map<string,int>
#define lowbit(x) ((x)&(-(x)))
#define ce(i, r) i==r?'\n':' '
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
#define pr(x) cout<<#x<<": "<<x<<endl
using namespace std;

inline int qr() {
    int f = 0, fu = 1;
    char c = getchar();
    while (c < '0' || c > '9') {
        if (c == '-')fu = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        f = (f << 3) + (f << 1) + c - 48;
        c = getchar();
    }
    return f * fu;
}

const int MOD = 1e9 + 7;

ll qpow(ll x, ll n, ll mod = MOD) {
    if (n == 0) return 1;
    ll res = qpow((x * x) % mod, n / 2, mod) % mod;
    if (n & 1) res = (res * x) % mod;
    return res % mod;
}

int n;

int main() {
    n = qr();
    pl((qpow(10, n) - (2 * qpow(9, n) % MOD - qpow(8, n) % MOD + MOD) % MOD + MOD) % MOD);
    return 0;
}

Measured memory_bytes: 3692
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<typename T, bool ismin=true>
struct SkewHeap{
	struct Node{
		T key;
		Node *l, *r;
	};
	SkewHeap(){}

	Node *merge(Node *x, Node *y){
		if(!x) return y;
		if(!y) return x;
		if((x->key < y->key)^ismin) swap(x, y);
		x->r=merge(x->r, y);
		swap(x->l, x->r);
		return x;
	}

	void push(Node *&root, const T &key){
		root=merge(root, new Node({key, nullptr, nullptr}));
	}

	T top(Node *root){
		return root->key;
	}

	T pop(Node *&root){
		T top=root->key;
		auto *temp=root;
		root=merge(root->l, root->r);
		delete temp;
		return top;
	}

	bool empty(Node *root) const{
		return !root;
	}

	Node *makeheap(){
		return nullptr;
	}
};
int main()
{
	SkewHeap<int, false> heap;
	auto root=heap.makeheap();
	while(1){
		string s;
		cin>>s;
		if(s=="end") return 0;
		if(s=="insert"){
			int k; cin>>k;
			heap.push(root, k);
		}else{
			cout<<heap.pop(root)<<"\n";
		}
	}
    return 0;
}


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

#define sz(x) (int)(x.size())
#define FOR(x,y,z) for(int x = y; x <= z; x++)
#define int long long

const int N = 1e5 + 2, inf = 1e18;

int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);  
    
    int n = 5;
    FOR(i,1,n){
        int u;
        cin >> u;
        if(u == 0){
            cout << i << '\n';
            return 0;
        }
    }
}

Measured memory_bytes: 3568
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")

//# include <x86intrin.h>
# include <bits/stdc++.h>

# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
 
template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
int a[N];
int b[N];
int tong[N];
//	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//	shuffle(permutation.begin(), permutation.end(), rng);



bool check (int x) {
	/*ordered_set < pair < int, int > > q;
	ll ans = 0;
	q.insert({0, 0});
	for (int i = 1; i <= n; ++i) {
		b[i] = b[i-1];
		if (a[i] >= x) b[i]++;
		else b[i]--;
		ans += q.order_of_key({b[i], n+1});
  		q.insert({b[i], i});
	}*/
	memset(tong,0,sizeof(tong));
	int dq = n, dd = 1; ll ans = 0;
	tong[n] = 1; 
	for(int i=1;i<=n;i++){
		if(a[i] >= x) dd += tong[++dq];
		else dd -= tong[dq--];
		
		ans += dd++; 
		tong[dq]++;
	}
	ll overall = n * (ll)(n+1) / 2;

	return ans * 2 >= overall;
}

int main () {
	scanf("%d", &n);
	vector < int > val;
	for (int i = 1; i <= n; ++i) {
		scanf("%d", a + i);
		val.pb(a[i]);
	}
	sort(every(val));
	val.resize(unique(every(val)) - val.begin());

	int l = 0, r = sz(val);
	while (r - l > 1) {
		int md = (l + r) >> 1;
		if (check(val[md])) {
			l = md;
		} else {
			r = md;
		} 
	}

	printf("%d\n", val[l]);

	return Accepted;
}

// B...a

Measured memory_bytes: 6904
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd


def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
    n=INT()
    d=LIST()
    d.sort()

    print(max(0,d[int(n/2)]-d[int(n/2-1)]))

if  __name__=='__main__':
    main()


Measured memory_bytes: 15900
#include <stdio.h>


int main(int argc, char **argv)
{
  int a,b,xxx,i,j;
  int x[3];
  scanf("%d %d",&a,&b);
  x[0] = a + b;
  x[1] = a - b;
  x[2] = a * b;
  for(i = 0 ; i < 2 ; i++){
    for(j = i ; j < 2 ; j++){
      if(x[j] > x[j + 1]){
        xxx = x[j];
        x[j] = x[j + 1];
        x[j + 1] = xxx;
      }
    }
  }
  printf("%d\n",x[2]);  

  return 0;
}


Measured memory_bytes: 128
#include "iostream"
using namespace std;
#include <stdio.h>

int main(int argc, char const *argv[])
{
	int H,W;
	int i,j=0;
	while(true){
		cin >> H >> W;
		if ((H == 0) && (W == 0))
		{
			break;
		}
		for(j = 0; j < H; j++){
			for (i = 0; i < W; ++i)
			{
				cout << '#';
			} 
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3100
use std::io;
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}


fn main() {
    let mut l = 200;
    let mut r = 0;
    for _ in 0..5 {
        let a: usize = read_line().trim().parse().unwrap();
        l = cmp::min(l, a);
        r = cmp::max(r, a);
    }
    let k: usize = read_line().trim().parse().unwrap();

    if r - l > k {
        println!(":(");
    } else {
        println!("Yay!");
    }
}


Measured memory_bytes: 4352
import numpy as np

N, D = map(int, input().split())

X = [0] * N

for i in range(N):
    X[i] = list(map(int, input().split()))

count = 0

for i in range(N-1):
    for j in range(i+1, N):
        distance = np.linalg.norm(np.array(X[i]) - np.array(X[j]))
        if distance == int(distance):
            count += 1

print(count)

Measured memory_bytes: 21424
#include<cstdio>
#include<map>
#define maxn 100005
using namespace std;
int n,a[maxn],b[maxn],fa[maxn],siz[maxn],cnt,ans;
map<int,int> mp,val;
int find(int x)
{
	if(fa[x]==x) return x;
	return fa[x]=find(fa[x]);
}
int main()
{
	scanf("%d",&n);
	int x=0;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		mp[a[i]]++; x^=a[i];
		if(!val[a[i]]) val[a[i]]=++cnt;
	}
	mp[x]++;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&b[i]);
		if(!mp[b[i]]) { printf("-1\n"); return 0; }
		mp[b[i]]--;
		if(!val[b[i]]) val[b[i]]=++cnt;
	}
	for(int i=1;i<=cnt;i++) fa[i]=i,siz[i]=1;
	for(int i=1;i<=n;i++)
		if(a[i]!=b[i])
		{
			int r1=find(val[a[i]]),r2=find(val[b[i]]);
			if(r1!=r2) fa[r1]=r2,siz[r2]+=siz[r1];
			ans++;
		}
	bool f=true;
	for(int i=1;i<=n;i++)
		if(a[i]!=b[i]) { f=false; break; }
	if(f) { printf("0\n"); return 0; }
	if(!val[x]) ans++;
	for(int i=1;i<=cnt;i++)
		if(find(i)==i&&siz[i]>1) ans++;
	printf("%d\n",ans-1);
}

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

int main(int argc, char const* argv[])
{
    string s;
    cin >> s;

    int n = 0;

    for (int i = 0; i < 4; i++) {
        if (s[i] == '+') {
            n++;
        }else{
            n--;
        }
    }

    cout << n << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int x,y;
	
	scanf("%d",&x);
	scanf("%d",&y);
	
	if(x==y) {
		printf("Draw\n");
	}
	else if(x==1) {
		printf("Alice\n");
	}
	else if(y==1) {
		printf("Bob\n");
	}
	else if(x>y) {
		printf("Alice\n");
	}
	else if(x<y) {
		printf("Bob\n");
	}
	return 0;
}
	

Measured memory_bytes: 128
import sys
import numpy as np

N = int(input())
p_in = np.array(list(map(int, input().split())))

p_a = np.arange(N) +1


cnt = 0
for i in range(N):
    if p_in[i] == p_a[i]:
        continue
    else:
        cnt += 1


if cnt <= 2:
    print('YES')
else:
    print('NO')


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

/*
#include <algorithm>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <vector>
#include <set>
*/

using namespace std;

typedef long long LL;
typedef double DB;
typedef unsigned int UI;
typedef pair<int, int> PII;

const int inf = 0x7f7f7f7f;

#define rdi() read<int>()
#define rdl() read<LL>()
#define rds(a) scanf("%s", a)
#define mk(i, j) make_pair(i, j)
#define pb push_back
#define fi first
#define se second
#define For(i, j, k) for (int i = j; i <= k; i ++)
#define Rep(i, j, k) for (int i = j; i >= k; i --)
#define Edge(i, u) for (int i = head[u]; i; i = e[i].nxt)

template<typename t> t read() {
	t x = 0; int f = 1; char c = getchar();
	while (c > '9' || c < '0') f = c == '-' ? -1 : 1 , c = getchar();
	while (c >= '0' && c <= '9') x = x * 10 + c - 48 , c = getchar();
	return x * f;
}

template<typename t> void write(t x) {
	if (x < 0){
		putchar('-'), write(-x);
		return;
	}
	if (x >= 10) write(x / 10);
	putchar(x % 10 + 48);
}

const int N = 3e5 + 10;
int a[N], b[N], n;

int main() {
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);
	n = rdi();
	for (int i = 1; i <= n; i ++) a[i] = rdi();
	int l = 1, r = n, k = 0;
	for (int i = n; i; i --) {
		if (!k) b[l++] = a[i];
		else b[r --] = a[i];
		k ^= 1;
	}
	for (int i = 1; i <= n; i ++) write(b[i]), putchar(32);
	return 0;
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())

const ll mod=1e9+7;

//vector書き出し
template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}

typedef pair<int,int> P;

//dijkstra
struct edge{
    ll to,cost;
};
ll INF=1e15;
vector<edge> g[100010];
//vector<ll> d(100010);

ll n,m,r;
vector<vector<ll> > mi(300,vector<ll>(300));//mi[i][j]→iからスタートした時のjへの最短
 
void dijkstra(ll x,vector<ll> &d){
    rep(i,len(d)){
        d[i]=INF;
    }
    priority_queue<P,vector<P>,greater<P> > que;
    d[x]=0;
    que.push(P(0,x));
    while(!que.empty()){
        P p=que.top();
        que.pop();
        ll v=p.second;
        if(d[v]<p.first){
            continue;
        }
        rep(i,len(g[v])){
            edge e=g[v][i];
            if(d[e.to]>d[v]+e.cost){
                d[e.to]=d[v]+e.cost;
                que.push(P(d[e.to],e.to));
            }
        }
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n>>m>>r;
    vector<ll> en(r);
    rep(i,r){
      cin>>en[i];
    }
    sort(begin(en),end(en));
    rep(i,m){
      ll a,b,c;
      cin>>a>>b>>c;
      g[a].push_back({b,c});
      g[b].push_back({a,c});
    }
    rep(i,r){
      dijkstra(en[i],mi[en[i]]);
    }
    ll ans=1e18;

    do{
      ll cnt=0;
      rep(i,r-1){
        cnt+=mi[en[i]][en[i+1]];
      }
      if(cnt<ans){
        ans=cnt;
        //cout<<ans<<' '<<en[0]<<' '<<en[1]<<' '<<en[2]<<'\n';
      }
    }while(next_permutation(begin(en),end(en)));
    cout<<ans<<endl;
}

Measured memory_bytes: 4224
#include <iostream>

using namespace std;

int gcd(int x, int y)
{
	if(x%y == 0) return y;
	return gcd(y, x%y);
}

int main()
{
	int x, y;
	cin >> x >> y;
	cout << gcd(max(x, y), min(x, y)) << endl;
}





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

int main() {
  string s;
  int s1,s2,s3;
  cin>>s;
  s1=s[0]-'0',s2=s[1]-'0',s3=s[2]-'0';
  cout<<s1+s2+s3<<endl;
}

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

int main()
{
    long long int n,m,i,j;
    cin>>n>>m;

    long long int dp[n][m];

    for(i=0;i<n;i++)
        for(j=0;j<m;j++)
            dp[i][j]=-1;

    for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++)
        {
            char c;
            cin>>c;
            if(c=='#')
                dp[i][j]=0;
        }
    }

    dp[0][0]=1;

    for(i=1;i<m;i++)
    {
        if(dp[0][i]==-1)
            dp[0][i]=dp[0][i-1];
    }

    for(i=1;i<n;i++)
    {
        if(dp[i][0]==-1)
            dp[i][0]=dp[i-1][0];
    }

    for(i=1;i<n;i++)
    {
        for(j=1;j<m;j++)
        {
            if(dp[i][j]==-1)
            {
                dp[i][j]=dp[i-1][j]+dp[i][j-1];
                dp[i][j]%=1000000007;
            }
        }
    }

    cout<<dp[n-1][m-1]%1000000007;
}


Measured memory_bytes: 8064
#include<stdio.h>
#define NOT_FOUND 100000000

int binarySearch(int A[], int n, int key){
    int left, right, mid;
	
	
	
	left = 0;
    right = n;
	while (left < right){
        mid = (left + right) / 2;
		if (A[mid] == key) return mid;//見つけた
		else if (key < A[mid]) right = mid;
        else left = mid + 1;
	}
    return NOT_FOUND;
}


int main(void){
	
	int n, i, q;
	
	scanf("%d", &n);
	int S[n];
	
	for(i=0; i<n; i++){
		scanf(" %d", &S[i]);
		//printf("S%d\n", S[i]);
	}
	
	scanf("%d", &q);
	int T[q];
	
	for(i=0; i<q; i++){
		scanf(" %d", &T[i]);
		//printf("T%d\n", T[i]);
	}
	
	int k=0, a, A[q];
	
	for(i=0; i<q; i++){
		a = binarySearch(S, n, T[i]);
		if(a!=NOT_FOUND){//あった
			A[k]=a;
			k++;
		}
	}
	
	
	printf("%d\n", k);
	/*for(i=0; i<k-1; i++){
		printf("%d ", A[i]);
	}
	printf("%d", A[k]);
	*/
	
	return 0;
}


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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	int a[n];
	for (int i = 0; i < n; i++) a[i] = ri();
	auto min = std::min_element(a, a + n);
	auto max = std::max_element(a, a + n);
	std::vector<std::pair<int, int> > res;
	if (-*min > *max) { // minus strong
		for (int i = 0; i < n; i++) if (a[i] > 0) {
			a[i] += *min;
			res.push_back({min - a, i});
		}
		for (int i = n - 1; i; i--) res.push_back({i, i - 1});
	} else {
		for (int i = 0; i < n; i++) if (a[i] < 0) {
			a[i] += *max;
			res.push_back({max - a, i});
		}
		for (int i = 0; i + 1 < n; i++) res.push_back({i, i + 1});
	}
	std::cout << res.size() << std::endl;
	for (auto &i : res) std::cout << i.first + 1 << " " << i.second + 1 << std::endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const string temp = "^>v<";
const int dy[] = {-1, 0, 1, 0}, dx[] = {0, 1, 0, -1};

int N, M;
string S[52];
int sx, sy, sd;

int bfs()
{
  bool f[52][52] = {{}}, v[52][52][4] = {{}};

  while(!v[sy][sx][sd]++) {
    f[sy][sx] = true;
    int nd = (sd + 1) % 4;
    int nx = sx + dx[nd], ny = sy + dy[nd];

    if(S[sy][sx] == 'G') {
      int ret = 0;
      for(int i = 1; i <= N; i++) {
        ret += count(f[i], f[i] + M + 2, true);
      }
      return(ret);
    } else if(S[ny][nx] == '#') {
      if(S[sy + dy[sd]][sx + dx[sd]] == '#') {
        sd = (sd + 3) % 4;
      } else {
        sx += dx[sd];
        sy += dy[sd];
      }
    } else {
      sd = (sd + 1) % 4;
      sx += dx[sd];
      sy += dy[sd];
    }
  }
  return(-1);
}

int main()
{
  cin >> N >> M;
  for(int i = 1; i <= N; i++) {
    cin >> S[i];
    S[i] = "#" + S[i] + "#";
    for(int j = 1; j <= M; j++) {
      if(temp.find(S[i][j]) != string::npos) {
        sx = j;
        sy = i;
        sd = temp.find(S[i][j]);
      }
    }
  }
  S[0] = S[N + 1] = string(M + 2, '#');
  cout << bfs() << endl;
}

Measured memory_bytes: 1244
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string str;
	cin>>str;
	int n=str.length();
	int sum=0;
	for(int i=0;i<n;i++)
	{
		sum+=(str[i]-'0');
	}	
	if(sum%9==0)
	{
		cout<<"Yes";
	}
	else
		cout<<"No";
}

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

typedef complex<double> Point;

#define EPS (1e-10)
#define EQ(a,b) (abs((a)-(b)) < EPS)
#define EQV(a,b) ( EQ( (a).real() , (b).real() ) && EQ( (a).imag(), (b).imag() ) )

//OÏ a~b
double cross(Point a,Point b) {
  return (a.real()*b.imag() - a.imag()*b.real());
}

//¼üÌ½s»è
int is_parallel(Point a1,Point a2,Point b1,Point b2){
  return EQ( cross(a1-a2,b1-b2) , 0.0 );
}

int main(){
  int n;
  double x1,y1,x2,y2,x3,y3,x4,y4;
  cin>>n;
  while(n--){
    cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4;
    Point p1(x1,y1),p2(x2,y2),p3(x3,y3),p4(x4,y4);
    if( is_parallel(p1,p2,p3,p4)){
      cout<<"YES"<<endl;
    }else{
      cout<<"NO"<<endl;
    }
  }
}

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

using ll = long long int;
const int mod = 1e9+7;
const int inf = 1e9+5;


int main(){
	
	int n, K;
	cin>>n>>K;
	vector<int>arr(n);
	for(int i = 0; i < n; i++){
		cin>>arr[i];
	}
	vector<int>dp(n, inf);
	///dp[i] denote mininum till ith index
	dp[0] = 0;
	for(int i = 1; i < n; i++){
		for(int k = 1; k <= K; k++){
			if(i-k >= 0){ /// don't use (k-i>=K)
				//cout<<i<<endl;
				dp[i] = min(abs(arr[i]-arr[i-k])+dp[i-k], dp[i]);
			}
		}
	}
	cout<<dp[n-1]<<endl;
	//for(int i = 0; i < n; i++){
		//cout<<dp[i]<<' ';
	//}
	//cout<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#define R 1000
#define TMAX 1261
using namespace std;
int main(){
  int N,M,r,q,t[R],n[R],m[R],s[R],end[R],ts,te,m1,cnt,lim,time[TMAX];
  while(1){
    cin >> N >> M;
    if(N==0&&M==0) break;
    cin >> r;
    for(int i=0;i<r;i++){
      cin >> t[i] >> n[i] >> m[i] >> s[i];
    }
    cin >> q;
    for(int i=0;i<q;i++){
      cin >> ts >> te >> m1;
      for(int j=ts;j<=te;j++){
	time[j]=0;
      }
      for(int j=0;j<r;j++) end[j]=0;
      cnt=0;
      for(int j=0;j<r;j++){
	if(end[j]==0){
	  end[j]=1;
	  if(m1==m[j]){
	    for(int k=j+1;k<r;k++){
	      if(m1==m[k]&&n[j]==n[k]&&end[k]==0){
		end[k]=1;
		for(int l=t[j]+1;l<=t[k];l++){
		  if(time[l]==0&&ts<l&&l<=te){
		    time[l]=1;
		    cnt++;
		  }
		}
		break;
	      }
	    }
	  }
	}
      }
      cout << cnt << endl;
    }
  }
  return 0;
}

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

int main() {
    int N;
    int a[110];
    cin >> N;
    for(int i = 0; i < N; ++i) cin >> a[i];
    
    sort(a, a + N, greater<int>());
    int Alice = 0;
    int Bob = 0;
    for(int i = 0; i< N; ++i) {
        if(i % 2 == 0) {
            Alice += a[i];
        }
        else {
            Bob += a[i];
        }
    }
    cout << Alice - Bob << endl;
}


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

#define fi first
#define se second
#define U unsigned
#define P std::pair<int,int>
#define LL long long
#define pb push_back
#define MP std::make_pair
#define all(x) x.begin(),x.end()
#define CLR(i,a) memset(i,a,sizeof(i))
#define FOR(i,a,b) for(int i = a;i <= b;++i)
#define ROF(i,a,b) for(int i = a;i >= b;--i)
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl

std::map<LL,LL> S;
LL n,a,b,c,d;

inline LL dp(LL n){
    if(S.count(n)) return S[n];
    LL res = 1e18;
    if(n <= res/d) res = n*d;
    LL t = n/2;
    res = std::min(res,dp(t)+a+std::abs(n-2*t)*d);
    t = (n+1)/2;
    res = std::min(res,dp(t)+a+std::abs(n-2*t)*d);
    t = n/3;
    res = std::min(res,dp(t)+b+std::abs(n-3*t)*d);
    t = (n+2)/3;
    res = std::min(res,dp(t)+b+std::abs(n-3*t)*d);
    t = n/5;
    res = std::min(res,dp(t)+c+std::abs(n-5*t)*d);
    t = (n+4)/5;
    res = std::min(res,dp(t)+c+std::abs(n-5*t)*d);
    return S[n] = res;
}

inline void Solve(){
    S.clear();scanf("%lld%lld%lld%lld%lld",&n,&a,&b,&c,&d);
    S[0] = 0;S[1] = d;
    printf("%lld\n",dp(n));
}

int main(){
    int T;scanf("%d",&T);
    while(T--) Solve();
    return 0;
}


Measured memory_bytes: 4468
N = int(input())
h = [int(x) for x in input().split()]
ans = [0]*N
ans[0] = 0
for i in range(1,N):
    if h[i] <= h[i-1]:
        ans[i] = ans[i-1] + 1
    else:
        ans[i] = 0
print(max(ans)) 

Measured memory_bytes: 63984
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String O = sc.next();
    String E = sc.next();
    StringBuilder A = new StringBuilder();
    System.out.println(A);
    for (int i = 0; i < E.length(); i++) {
      A.append(O.charAt(i));
      A.append(E.charAt(i));
    }
    if (O.length() > E.length()) {
      A.append(O.charAt(O.length() - 1));
    }
    System.out.println(A);
  }
}


Measured memory_bytes: 22612
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#include<string.h>
#include<math.h>
#include<ctype.h>
#define MOD 10000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define revrep(i,n) for(ll i=n;i>0;i--)

typedef long long ll;

ll fac[100001], inv[100001];

ll mygcd(ll a, ll b) { if (b == 0) return a; return mygcd(b, a % b); }

ll mylcm(ll a, ll b) { return a / mygcd(a, b) * b; }

ll mymax(ll a, ll b) { return (a > b) ? a : b; }

ll mymin(ll a, ll b) { return (a < b) ? a : b; }

int myasc(const void* a, const void* b) { return *(ll*)a - *(ll*)b; }

int mydsc(const void* a, const void* b) { return *(ll*)b - *(ll*)a; }

ll mypow(ll a, ll b) {
	ll x;
	if (b == 0) return 1;
	else if (b % 2 == 1) return a * mypow(a, b - 1) % MOD;
	x = mypow(a, b / 2);
	return x * x % MOD;
}

ll mycomb(ll a, ll b) {
	if (a < b || a < 0 || b < 0)return 0;
	return fac[a] * inv[a - b] * inv[b] % MOD;
}

int main() {
	bool flag = false;
	ll n, k,a[200000];
	scanf("%lld%lld",&n,&k);
	rep(i, n) scanf("%lld", &a[i]);
	rep(i, n-k) {
		if (a[k + i] > a[i]) printf("Yes\n");
		else printf("No\n");
	}

	return 0;
}

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

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

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

#define x1 gray_cat_x1
#define y1 gray_cat_y1

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

#define file "I1"

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

const int MAXN = 1e5 + 5;

int used_s[MAXN];

void solve(){
	int a, b, c, d, e, f;
	cin >> a >> b >> c >> d >> e >> f;
	REPN(i, 0, f / c){
		int v1 = i * c;
		REPN(j, 0, (f - v1) / d){
			int v2 = v1 + j * d;
			if (v2 <= f){
				used_s[v2] = 1;
			}
		}
	}
	
	/*REPN(i, 0, 3000){
		printf("%d %d\n", i, used_s[i]);
	}*/
	
	int ans_w = 0, ans_s = 0;
	REPN(i, 0, 100){
		REPN(j, 0, 100){
			int cnt_w = 100 * i * a + 100 * j * b;
			if (cnt_w == 0){
				continue;
			}
			if (cnt_w <= f){
				REPN(cnt_s, 0, f - cnt_w){
					if (used_s[cnt_s] && cnt_s * 100 <= e * cnt_w){
						if (ans_w == 0 && ans_s == 0 || cnt_s * (ans_s + ans_w) > (cnt_w + cnt_s) * ans_s){
							ans_w = cnt_w;
							ans_s = cnt_s;
						}
					}
				}
			}
		}
	}
	cout << ans_w + ans_s << " " << ans_s << endl;
}   

int main(){

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


Measured memory_bytes: 256
#import math

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def count_multiple(A, B, x):
    """B と　A-1 までのxの倍数の数をかぞえる
    引けばA,B範囲内の倍数の数"""
    min_value = (A - 1) // x
    max_value = B // x
    
    return max_value - min_value


A, B, C, D = [int(i) for i in input().split()]

# lcm = C * D // math.gcd(C, D)
lcm = C * D // gcd(C, D)
cnt = 0
for i, x in enumerate([C, D, lcm]):
    if i < 2:
        cnt += count_multiple(A, B, x)
    else:
        cnt -= count_multiple(A, B, x)

total = B - (A - 1)
ans = total - cnt
print(ans)

Measured memory_bytes: 3064
/**
 * Я слил Atcoder Beginner Contest 172, решив всего две задачи!
 * Я не могу апнуть синего!
 * Я постоянно сливаю раунды, либо не решив тупую задачу, либо набрав штрафа!
 * Я постоянно уступаю всем своим друзьям и знакомым в контестах и нахожу этому оправдания!
 * Я постоянно придумываю сложные неверные решения к простым задачам!
 * -------------------------------------------------------------
 * -Решать сложные задачи
 * -Участвовать в контестах
 * -Делать виртуальные соревнования
 * -------------------------------------------------------------
 * Не уберу это, пока не начну нормально решать задачи, а не заниматься ерундой!!!
**/
  
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

typedef long long  ll;
#define press_F_to_pay_respect ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn for(int i=0;i<n;i++) 
#define fore(i,a,b) for(int i = a; i < (b); i++)
#define pb push_back 
#define pob pop_back()
#define mp make_pair 
#define sc second 
#define f first 
#define ld long double
#define kek cout<<endl; 
#define rep(i,a,b) for(int i=a;i<b;i++)
#define all(v) ((v).begin()), ((v).end()) 
#define halt {cout<<"NO"; return 0;}
const ll MOD = 1e9 + 7;
const ll MOD1 = 998244353;
const int N = 200010;
const int INF = 1e8;
const ll LL_INF=1e10;
const long double pi=3.1415926535;
using namespace std;
using namespace __gnu_pbds;
typedef tree<ld,null_type,less<ld>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
// Template functions
string bin_rep(ll n)
{
     string s="";
      for(int i=63;i>=0;i--)
   {
           if(n&(1LL<<i)) s+='1';
           else s+='0';
   }
   return s;
}
int first_bit(int n)
{
  for(int i=0;i<=31;i++)
   {
           if(n&(1<<i)) return i;
   }
}

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

int main()
{
    #if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
    #endif
 press_F_to_pay_respect;
 // cout << fixed << setprecision(12) << ans;
 // string al = "abcdefghijklmnopqrstuvwxyz";
 int n;
 cin>>n;
 vector<int> v(n);
 forn cin>>v[i];
 int cnt=0;
 forn
 {
           if((i+1)&1 && v[i]&1) cnt++;
 }
 cout<<cnt;
 

 
 
  // cout <<"Runtime is:"<<clock() * 1.0 / CLOCKS_PER_SEC <<endl;
   return 0;
   
   
 
}

Measured memory_bytes: 3612
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
  int N = sc.nextInt();
  int M = sc.nextInt();
  int[] s = new int[2*N];
  int[] c = new int[2*M];
  for(int i = 0;i < 2*N;i++)s[i] = sc.nextInt();
  for(int i = 0;i < 2*M;i++)c[i] = sc.nextInt();
  for(int i = 0;i < 2*N;i += 2){
    long min = 99999999999l;
    int ans = 0;
    for(int j = 0;j < 2*M;j +=2){
      if(Math.abs(s[i]-c[j])+Math.abs(s[i+1]-c[j+1]) < min){
        min = Math.abs(s[i]-c[j])+Math.abs(s[i+1]-c[j+1]);
        ans = (j/2)+1;
      }
    }
    System.out.println(ans);
  }
}}


Measured memory_bytes: 23636
//
//  first.cpp
//  CoderTest
//
//  Created by yuya on 2019/07/25.
//  Copyright © 2019 yuya. All rights reserved.
//

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;



int main()
{
    string S;
    cin >> S;
    S = S.substr(0,2);
    if(S == "SU"){
        cout << 7 << endl;
        
    } else if(S == "MO"){
        cout << 6 << endl;
        
    } else if(S == "TU"){
        cout << 5 << endl;
        
    } else if(S == "WE"){
        cout << 4 << endl;
        
    } else if(S == "TH"){
        cout << 3 << endl;
        
    } else if(S == "FR"){
        cout << 2 << endl;
        
    } else if(S == "SA"){
        cout << 1 << endl;
        
    }
    
    
    return 0;
}



Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class BPalindromePhilia {
public:
    static constexpr int kStressIterations = 0;
    static void generateTest(std::ostream& test) {
    }

    void solve(std::istream& cin, std::ostream& cout) {
        string s;
        cin >> s;
        int l = 0;
        int r = s.size() - 1;

        int res = 0;
        while (l < r) {
            if (s[l] != s[r]) res++;
            l++;
            r--;
        }
        cout << res << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    BPalindromePhilia solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <bits/stdc++.h>
#include<stdio.h>
#include <stdlib.h>
#include<string>
#include<queue>
#include<algorithm>
#include<math.h>
using namespace std;

int main(){
	int N,ans=0;
	int a[4000];
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>a[i];
		ans+=a[i]-1;
	}
	cout<<ans<<endl;
}


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

int main(){
        int i, x, n, left=103, right=103;
        scanf("%d %d", &x, &n);

        if(n==0){
                printf("%d", x);
                return 0;
        }

        int p[105]={0};
        int pp;

        for(i=0; i<n; i++){
                scanf("%d", &pp);
                p[pp]=1;
        }

        int count=0;

        for(i=0; i<101; i++){
                if(p[x+i]!=1){
                        right=x+i;
                        count++;
                }
                if(p[x-i]!=1){
                        left=x-i;
                        count++;
                }

                if((count!=0)&&(left>right)){
                        printf("%d", right);
                        return 0;
                }else if((count!=0)&&(right>=left)){
                        printf("%d", left);
                        return 0;
                }

        }

        return 0;
}


Measured memory_bytes: 1692
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,o,OP;
    set<int> ST;
    cin >> N;
    for (int i =0; i < N; i++){
        cin >> o;
        ST.insert(o);
    }
    OP = ST.size();
    cout << OP << endl;
}

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

#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

int main(void){
    ll n;
    cin>>n;
    cout<<n<<":";
    int N=n;
    vector<pair<int,int>> res;
    for(int i=2;i*i<=N;i++){
        int ex=0;
        while(n%i==0){
            ex++;
            n/=i;
        }
        res.push_back({i,ex});
    }
    if(n!=1)res.push_back({n,1});

    for(auto p:res){
        for(int i=0;i<p.second;i++)cout<<" "<<p.first;
    }
    cout<<endl;
}




Measured memory_bytes: 3240
#include<iostream>

using namespace std;

int main(){
  int n;
  cin >> n;
  int i=0,tableCount=0,maxTableCount=0;;
  while(i++<n){
    int a,b;
    cin >> a>> b;
    if(a==b){
      tableCount++;
    } else {
      tableCount=0;
    }
    maxTableCount = max(tableCount,maxTableCount);
  }
  if(maxTableCount>2){
    cout<<"Yes"<<endl;
  } else {
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 3632
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cstring>
#include <vector>
#include <stack>
#include <deque>
#include <queue>
#include <cstdlib>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
typedef long long int ll;
#define forn for(int i=0;i<n;i++) 
#define form for(int j=0;j<n;j++) 
#define pb push_back 
#define mp make_pair 
#define sc second 
#define f first 
#define kek cout<<"\n" 
#define all(v) ((v).begin()), ((v).end()) 
#define pob pop_back() 
const ll MOD = 1e9 + 7;
const int N = 100005;
const ll INF = 1e9;
using namespace std;
int main()
{
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int n, x;
	cin >> n >> x;
	if (500 * n >= x) cout << "Yes";
	else cout << "No";
	return 0;
}

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

bool G[10][10];

int main(){
    int n, m; cin >> n >> m;
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b; a--; b--;
        G[a][b] = G[b][a] = true;
    }
    vector<int> v(n);
    rep(i,n) v[i] = i;
    int res = 0;
    do{
        if(v[0] != 0) break;
        bool ok = true;
        for(int i = 0; i+1 < n; i++){
            int from = v[i];
            int to = v[i+1];
            if(!G[from][to]) ok = false;
        }
        if(ok) res++;
    }while(next_permutation(v.begin(),v.end()));
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 105


int main () {
  int n, m, i, j, k, l, adj[N][N];

  for(i = 0 ; i < N ; i++) {
    for(j = 0 ; j < N ; j++) {
      adj[i][j] = 0;
    }
  }
  scanf("%d",&n);

  for(i = 1 ; i <= n ; i++) {
    scanf("%d %d",&l,&m);

    for(j = 1 ; j <= m ; j++) {
      scanf("%d",&k);

      adj[l][k] = 1;
    }
  }

  for(i = 1 ; i <= n ; i++) {
    for(j = 1 ; j <= n ; j++) {
      if(j == n) printf("%d\n",adj[i][j]);
      else printf("%d ",adj[i][j]);
    }
  }

  return 0;
}



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

int helper(vector<vector<int>>& v , int last , int ind,int n,vector<vector<int>>& dp){
	
   if(ind == n){
   return 0;
   }
   if( ind<n && last>=0 && last<=2 && dp[last][ind]!=0){
       return dp[last][ind];
   }
    int a=0,b=0,c=0;

    if(last!=0 )
       a = helper(v ,  0 , ind+1,n,dp) + v[0][ind];

    if(last!=1 )
       b = helper(v ,  1 , ind+1,n,dp) + v[1][ind];

       if(last!=2 )
       c = helper(v ,  2 , ind+1,n,dp) + v[2][ind];

if(last!=-1)
  dp[last][ind]=max(a,max(b,c));

return max(a,max(b,c));

}



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

int n;
cin>>n;

vector<vector<int>>v(3 , vector<int>(n));

for(int i=0;i<n;i++){
	int a,b,c;
	cin>>a>>b>>c;
   v[0][i]=a;
   v[1][i]=b;
   v[2][i]=c;
}

vector<vector<int>> dp(3, vector<int>(n+1,0));

cout<<helper(v,-1,0,n,dp)<<"\n";

}

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

vector<long> L,R,memo;

int main(void){
  long N,M;
  long maxl,minr;
  cin >> N >> M;
  L = R = vector<long>(M);
  minr = N+10;
  maxl = 1;
  for(long i=0;i<M;i++){
    cin >> L[i] >> R[i];
    maxl = max(maxl,L[i]);
    minr = min(minr,R[i]);
  }

  if(minr < maxl){
    cout << 0;
  }else{
    cout << minr-maxl + 1 << endl;
  }
}


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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int,V,greater<int>>

#define pb(a) push_back(a)
#define mp make_pair

#define dump(x)  cout << #x << " = " << (x) << "\n";
#define COUT(x) cout<<(x)<<"\n"


int main()
{
    int n = 0;
    cin >> n;
    vector<int> x(n);
    REP(i, n)
    {
        cin >> x[i];
    }
    int buf = 0;
    int ans = 0;
    REP(i,n)
    {
        cin >> buf;
        if (x[i] > buf)
        {
            ans += x[i] - buf;
        }
    }

    COUT(ans);

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <memory.h>

using namespace std;

int a, b, c, d;
int main()
{
	cin >> a >> b >> c >> d;
	int dis = a - c;
	if (dis < 0)
		dis = -dis;

	if (dis <= d)
		cout << "Yes" << endl;
	else {
		int x = a - b;
		if(x < 0)
			x = -x;
		int  y = b - c;
		if (y < 0)
			y = -y;

		if (x <= d && y <= d)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;

	}
	return 0;
}

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

static const auto fast_io = [] {
 ios_base::sync_with_stdio(false); 
 cin.tie(nullptr); cout.tie(nullptr); 
 return nullptr;
}();

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int rnd() {
 return uniform_int_distribution<int> (1, (int) 1e9) (rng);
}

template<class A> 
A rnd(A x, A y) {
 return uniform_int_distribution<A> (x, y) (rng);
}

string to_string(string s) {
 return '"' + s + '"';
}

string to_string(const char* ch) {
 return to_string((string)ch);
}

string to_string(char ch) {
 return (string)"'" + ch + (string)"'";
}

string to_string(bool b) {
 return (b ? "true" : "false");
}

template<class A, class B>
string to_string(pair<A, B> p) {
 return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template<class A>
string to_string(A a) {
 string res = "{";
 bool first = true;
 for(const auto& x: a) {
  if(first == false) res += ", ";
  first = false;
  res += to_string(x);
 }
 res += "}";
 return res;
}

template<class A, class B, class C>
string to_string(priority_queue<A, B, C> a) {
 vector<A> res;
 while(a.empty() == false) {
  res.push_back(a.top());
  a.pop();
 }
 reverse(res.begin(), res.end());
 return to_string(res);
}

template<class A>
string to_string(priority_queue<A> a) {
 vector<A> res;
 while(a.empty() == false) {
  res.push_back(a.top());
  a.pop();
 }
 reverse(res.begin(), res.end());
 return to_string(res);
}

template<class A>
string to_string(stack<A> a) {
 vector<A> res;
 while(a.empty() == false) {
  res.push_back(a.top());
  a.pop();
 }
 return to_string(res);
}

template<class A>
string to_string(queue<A> a) {
 vector<A> res;
 while(a.empty() == false) {
  res.push_back(a.front());
  a.pop();
 }
 return to_string(res);
}

vector<string> __vector_tuple;
template<int index, class... A>
struct print_tuple {
 auto operator() (tuple<A...> a) {
  __vector_tuple.push_back(to_string(get<index>(a)));
  print_tuple<index-1, A...>{}(a);
 }
};

template<class... A>
struct print_tuple<0, A...> {
 auto operator() (tuple<A...> a) {
  __vector_tuple.push_back(to_string(get<0>(a)));
 }
};

template<class... T>
string to_string(tuple<T...> a) {
 const int ttsz = tuple_size<decltype(a)>::value;
 print_tuple<ttsz-1, T...>{}(a);
 string __ss = to_string(__vector_tuple);
 __vector_tuple.clear();
 return __ss;
}

void debug() {cerr << "]\n";}

template<class H, class... T>
void debug(H head, T... tail) {
 cerr << to_string(head) << " ";
 debug(tail...);
}

#ifdef LOCAL
 #define debug(...) cerr << "[" << #__VA_ARGS__ << " ] = ["; debug(__VA_ARGS__);
#else 
 #define debug(...) 
#endif

typedef long long int ll;

const int maxn = 100;
vector<int> a(maxn*maxn*maxn);

int main()
{
 for(int x = 1; x <= maxn; x++) {
  for(int y = 1; y <= maxn; y++) {
   for(int z = 1; z <= maxn; z++) {
    int value = x*x + y*y + z*z + x*y + y*z + x*z;
    a[value]++;
   }
  }
 }
 int n;
 cin >> n;
 for(int i = 1; i <= n; i++) cout << a[i] << '\n';
 return 0;
}


Measured memory_bytes: 7064
from collections import deque

s = input() 
s_queue = deque(s)
q = int(input())

inverted = False

for _ in range(q):
  query = input()
  if query[0] == "1":
    inverted = not inverted 
  else:
    ti, fi, ci = query.split()
    if fi == "1" and inverted:
      s_queue.append(ci)
    elif fi == "1" and not inverted:
      s_queue.appendleft(ci)
    elif fi == "2" and inverted:
      s_queue.appendleft(ci)
    else:
      s_queue.append(ci)

if inverted:
  print("".join(s_queue)[::-1])
else:
  print("".join(s_queue))
  

Measured memory_bytes: 8820