akhauriyash/Code-Regression huggingface dataset:
/// Thank you tanakh!!!
///  https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

const INF: usize = 1e10 as usize;

fn main() {
    input!(n: usize, q: usize, a: [usize1; n], queries: [usize1; q]);

    let mut next = vec![INF; n];
    let mut prev = vec![INF; n];

    for i in 0..n {
        if i > 0 {
            prev[a[i]] = a[i - 1];
        }
        if i < n - 1 {
            next[a[i]] = a[i + 1];
        }
    }

    let mut start = a[0];
    let mut end = a[n - 1];

    for &q in queries.iter() {
        match (prev[q], next[q]) {
            (INF, INF) => {
                // do nothing
            }
            (INF, _) => {
                start = next[q];
                prev[start] = INF;

                prev[q] = end;
                next[q] = INF;

                next[end] = q;
                end = q;
            }
            (_, INF) => {
                end = prev[q];
                next[end] = INF;

                prev[q] = INF;
                next[q] = start;

                prev[start] = q;
                start = q;
            }
            _ => {
                let a = start;
                let b = prev[q];
                let c = next[q];
                let d = end;

                start = c;
                prev[c] = INF;

                prev[q] = d;
                next[d] = q;

                next[q] = a;
                prev[a] = q;

                next[b] = INF;
                end = b;
            }
        }
    }

    let mut cur = start;
    for i in 0..n {
        if i > 0 {
            print!(" ");
        }
        print!("{}", cur + 1);
        cur = next[cur];
    }
    println!();
}



Measured memory_bytes: 11072
#![allow(unused_imports)]

use std::cmp;
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::fmt::{Debug, Display};
use std::io::{self, Read};
use std::str::{self, FromStr};


fn solve(s: String) -> bool {
    s.chars().find(|&c| c == '9').is_some()
}


fn main() {
    let stdin = io::stdin();
    let mut sc = Scanner::new(stdin.lock().bytes());
    print_yesno(solve(sc.next()), "Yes", "No");
}


struct Scanner<R: Read> {
    buf: Vec<u8>,
    bytes: io::Bytes<R>,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(bytes: io::Bytes<R>) -> Self {
        Scanner {
            buf: Vec::with_capacity(256),
            bytes: bytes,
        }
    }

    fn next<T: FromStr>(&mut self) -> T
    where
        <T as FromStr>::Err: Debug,
    {
        self.buf.clear();
        for c in self.bytes
            .by_ref()
            .map(|c| c.unwrap())
            .skip_while(|&c| c == ' ' as u8 || c == '\n' as u8)
            .take_while(|&c| !(c == ' ' as u8 || c == '\n' as u8))
        {
            self.buf.push(c);
        }
        str::from_utf8(&self.buf).unwrap().parse().unwrap()
    }

    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        (0..n).map(|_| self.next()).collect()
    }

    fn pairs<A: FromStr, B: FromStr>(&mut self, n: usize) -> Vec<(A, B)>
    where
        <A as FromStr>::Err: Debug,
        <B as FromStr>::Err: Debug,
    {
        (0..n).map(|_| (self.next(), self.next())).collect()
    }

    fn trios<A: FromStr, B: FromStr, C: FromStr>(&mut self, n: usize) -> Vec<(A, B, C)>
    where
        <A as FromStr>::Err: Debug,
        <B as FromStr>::Err: Debug,
        <C as FromStr>::Err: Debug,
    {
        (0..n)
            .map(|_| (self.next(), self.next(), self.next()))
            .collect()
    }

    fn mat<T: FromStr>(&mut self, m: usize, n: usize) -> Vec<Vec<T>>
    where
        <T as FromStr>::Err: Debug,
    {
        (0..n).map(|_| self.vec(m)).collect()
    }
}


#[allow(dead_code)]
fn print_yesno(x: bool, yes: &'static str, no: &'static str) {
    println!("{}", if x { yes } else { no });
}


#[allow(dead_code)]
fn print_foreach<T: Display, I: IntoIterator<Item = T>>(xs: I) {
    for x in xs.into_iter() {
        println!("{}", x);
    }
}


#[allow(dead_code)]
fn print_or<T: Display>(x: Option<T>, or: &'static str) {
    if let Some(x) = x {
        println!("{}", x);
    } else {
        println!("{}", or);
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <map>
#include <set>
#include <string>
#define int long long
using namespace std;
multimap<string, int>m;
set<string>s;
signed main() {
	int q; cin >> q;
	for (int i = 0; i < q; i++) {
		int p; string k, l, r;
		cin >> p;
		if (p == 0) {
			cin >> k >> p;
			s.insert(k); m.insert(make_pair(k, p));
		}
		else if (p == 1) {
			cin >> k;
			for (auto i = m.lower_bound(k); i != m.upper_bound(k); i++)	cout << i -> second << endl;

		}
		else if (p == 2) {
			cin >> k;
			s.erase(k);
			m.erase(m.equal_range(k).first, m.equal_range(k).second);
		}
		else {
			cin >> l >> r;
			for (auto i = m.lower_bound(l); i != m.upper_bound(r); i++)cout << i -> first << ' ' << i -> second << endl;
		}
	}
}


Measured memory_bytes: 31020
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;




int main(){
    ll n;
    cin>>n;
    vector<ll> a(n),b(n);
    set<pll> A,B;
    for(int i=0;i<n;i++){
        cin>>a[i];
        A.insert({a[i],i});
    }
    for(int i=0;i<n;i++){
        cin>>b[i];
        B.insert({b[i],i});
    }
    vector<ll> dp(n,E);
    dp[0]=0;
    priority_queue<pll,vector<pll>,greater<pll>> Q;
    Q.push({0,0});
    while(!Q.empty()){
        pll w=Q.top();
        Q.pop();
        if(w.F!=dp[w.S]){continue;}
        auto i=A.find({a[w.S],w.S});
        ++i;
        if(i!=A.end() && dp[i->second]>dp[w.S]+abs(i->first-a[w.S])){
            dp[i->second]=dp[w.S]+abs(i->first-a[w.S]);
            Q.push({dp[i->second],i->second});
        }
        --i;
        if(i!=A.begin()){
            --i;
            if(dp[i->second]>dp[w.S]+abs(i->first-a[w.S])){
                dp[i->second]=dp[w.S]+abs(i->first-a[w.S]);
                Q.push({dp[i->second],i->second});
            }
        }
        i=B.find({b[w.S],w.S});
        ++i;
        if(i!=B.end() && dp[i->second]>dp[w.S]+abs(i->first-b[w.S])){
            dp[i->second]=dp[w.S]+abs(i->first-b[w.S]);
            Q.push({dp[i->second],i->second});
        }
        --i;
        if(i!=B.begin()){
            --i;
            if(dp[i->second]>dp[w.S]+abs(i->first-b[w.S])){
                dp[i->second]=dp[w.S]+abs(i->first-b[w.S]);
                Q.push({dp[i->second],i->second});
            }
        }
    }
    for(int i=0;i<n;i++){
        cout<<dp[i]<<endl;
    }
    
    
    
    
    
    return 0;
}



Measured memory_bytes: 18728
// luogu-judger-enable-o2
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int a[100005];
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	cin>>a[i];
	sort(a+1,a+1+n);
	int now=1;
	int ans=0;
	for(int i=1;i<=n-1;i++)
	{
		if(a[i]==a[i+1])
		{
			now++;
			now%=2;
		} 
		else
		ans+=now,now=1;
	} 
	cout<<ans+now<<endl;
	return 0;
}

Measured memory_bytes: 640
function main(input){
  const args = input.split(' ');
  const X = parseInt(args[0], 10);
  const t = parseInt(args[1], 10);
  if(X >= t){
    console.log(X-t);
  }else{
    console.log('0');
  }
}
  
main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 29716
#include<iostream>
#include<vector>
#include<cmath>
#define _GLIBCXX_DEBUG
using namespace std;

int main(){
  int L,flag=0;;
  cin>>L;
  vector<int> c;

  for(int i=1;i<=L;i++){
    int x;
    int size=c.size();
    cin>>x;
    if(x<0&&size==0){
      cout<<i<<endl;
      flag=1;
      break;
    }
    else if(x>0){
      int num;
      for(int j=0;j<size;j++){
        if(x==c[j]){
          num=i;
          flag=1;
        }
      }
      if(flag==1){
        cout<<num<<endl;
        break;
      }
      else c.push_back(x);
    }
    else if(x<0){
      if(c[size-1]!=-1*x){
        cout<<i<<endl;
        flag=1;
        break;
      }
      else c.pop_back();
    }
  }
  if(flag==0) cout<<"OK"<<endl;
  return 0;
}



Measured memory_bytes: 3164
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)









 
int main(){
    ll a, b;
    cin >> a >> b;
    if(a < 10 && b < 10){
        cout << a * b << endl;
    }
    else{
        cout << -1 << endl;
    }
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using P = pair<ll,ll>;
using um = unordered_map<ll,ll>;
#define fl cout<<flush;
#define endl '\n'
template <typename T> inline void prt(T v){cout<<v<<'\n';}
template <typename T> inline bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=(ll)1e9+7;
const ll MOD2=998244353;
const ld pi=3.14159265358979323846;
const ld eps=1e-10;

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> A(N,0);
    for(ll i=0;i<N;++i)cin>>A[i];
    ll Max=-INF;
    ll Min=INF;
    for(auto p: A)chmax(Max,p);
    for(auto p: A)chmin(Min,p);
    prt(Max-Min);
    return 0;
}



Measured memory_bytes: 3652
import sys
input = sys.stdin.readline
import heapq as hp

N, M = map(int, input().split())
graph = [[] for _ in range(N)]
for _ in range(M):
    l, r, c = map(int, input().split())
    graph[l-1].append((c, r-1))

for i in range(N-1):
    graph[i+1].append((0, i))

INF = 10**16
D = [INF for _ in range(N)] # 頂点iへの最短距離がD[i]
D[0] = 0 
q = [] # しまっていく優先度付きキュー
hp.heappush(q, (0, 0))

while q:
    nd, np = hp.heappop(q) # 一番距離が近いものを取ってくる
    if D[np] < nd: # 追加した後の残骸は見ない
        continue
    for d, p in graph[np]:
        if D[p] > D[np] + d: # 隣接するやつの中で今よりも近くなれるなら更新
            D[p] = D[np] + d
            hp.heappush(q, (D[p], p))

d = D[-1]
if d == INF:
    print(-1)
else:
    print(d)

Measured memory_bytes: 71600
#include <iostream>
#include <stdio.h>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <math.h>
#include <utility>
#include <stack>
#include <string.h>
#include <complex>
using namespace std;

const int INF = 1<<29;
const double EPS = 1e-8;
typedef vector<int> vec;
typedef pair<int,int> P;
struct edge{int to,cost;};


string str[10000];
vector<vec> g;
vector<bool> visited;
vec node_dim;

int dfs(int v){
    int count = 1;
    visited[v] = true;
    for(int i=0;i<g[v].size();i++){
        if(visited[g[v][i]]) continue;
        count += dfs(g[v][i]);
    }
    return count;
}

int main(){
    while(1){
        int n;
        scanf("%d",&n);
        if(!n)break;

        g.assign(26, vec());
        node_dim.assign(26, 0);
        set<int> use_alph;
        for(int i=0;i<n;i++){
            string str;
            cin >> str;
            int a = str[0]-'a', b = str[str.size()-1]-'a';
            g[a].push_back(b);
            g[b].push_back(a);
            node_dim[a]++;
            node_dim[b]--;
            if(!use_alph.count(a))use_alph.insert(a);
            if(!use_alph.count(b))use_alph.insert(b);
        }

        bool is_euler = true;
        for(int i=0;i<26;i++){
            if(node_dim[i]){
                is_euler = false;
                break;
            }
        }

        visited.assign(26,false);
        if(is_euler && dfs(0)==use_alph.size()){
            cout << "OK" << endl;
        }else{
            cout << "NG" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1452
import java.io.*;
import java.util.*;
import java.math.*;
import java.util.concurrent.*;

class Main
{
    static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	static FastScanner sc=new FastScanner(br);
    static PrintWriter out=new PrintWriter(System.out);
	static Random rnd=new Random();
	static int[] parent,size;
	
	static int find(int u)
	{
		if(parent[u]==u)
		{
			return u;
		}
		
		else
		{
			parent[u]=find(parent[u]);
			
			return parent[u];
		}
	}
	
	static void merge(int u,int v)
	{
		int x=find(u),y=find(v);
		
		if(x!=y)
		{
			parent[y]=x;
			
			size[x]=size[x]+size[y];
			
			size[y]=0;
		}
	}
	
    public static void main(String args[]) throws Exception
    {
		int n=sc.nextInt(),m=sc.nextInt();char[][] a=new char[n][];
		
		int[] cnt=new int[26];
		
		for(int i=0;i<n;i++)
		{
			a[i]=sc.next().toCharArray();
			
			for(int j=0;j<m;j++)
			{
				cnt[a[i][j]-'a']++;
			}
		}
		
		List<Integer> list=new ArrayList<>();
		
		parent=new int[n*m];size=new int[n*m];
		
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<m;j++)
			{
				parent[i*m+j]=(i*m)+j;
				
				size[i*m+j]=1;
			}
		}
		
		for(int i=0;i<n;i++)
		{
			for(int j=0,k=m-1;j<k;j++,k--)
			{
				merge(i*m+j,i*m+k);
			}
		}
		
		for(int j=0;j<m;j++)
		{
			for(int i=0,k=n-1;i<k;i++,k--)
			{
				merge(i*m+j,k*m+j);
			}
		}
		
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<m;j++)
			{
				if(find(i*m+j)==i*m+j)
				{
					list.add(size[i*m+j]);
				}
			}
		}
		
		Collections.sort(list);boolean ans=true;
		
	//	out.println(list);
		
		for(int i=list.size()-1;i>=0;i--)
		{
			int max=-1,ch=-1;
			
			for(int j=0;j<26;j++)
			{
				if(cnt[j]>max)
				{
					max=cnt[j];ch=j;
				}
			}
			
			if(max>=list.get(i))
			{
				cnt[ch]-=list.get(i);
			}
			else
			{
				ans=false;break;
			}
		}
		
		out.println(ans?"Yes":"No");out.close();
    }
}
class FastScanner
{
    BufferedReader in;
    StringTokenizer st;

    public FastScanner(BufferedReader in) {
        this.in = in;
    }
	
    public String nextToken() throws Exception {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }
	
	public String next() throws Exception {
		return nextToken().toString();
	}
	
    public int nextInt() throws Exception {
        return Integer.parseInt(nextToken());
    }

    public long nextLong() throws Exception {
        return Long.parseLong(nextToken());
    }

    public double nextDouble() throws Exception {
        return Double.parseDouble(nextToken());
    }
}

Measured memory_bytes: 22612
#include<vector>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define foreach(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
using namespace std;

//±ÒØ
typedef int Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;

bool augment(const Graph& g, int u,
    vector<int>& matchTo, vector<bool>& visited) {
  if (u < 0) return true;
  foreach(e, g[u]) if (!visited[e->dst]) {
    visited[e->dst] = true;
    if (augment(g, matchTo[e->dst], matchTo, visited)) {
      matchTo[e->src] = e->dst;
      matchTo[e->dst] = e->src;
      return true;
    }
  }
  return false;
}
int bipartiteMatching(const Graph& g, int L, Edges& matching) {
  const int n = g.size();
  vector<int> matchTo(n, -1);
  int match = 0;
  rep(u, L) {
    vector<bool> visited(n);
    if (augment(g, u, matchTo, visited)) ++match;
  }
  rep(u, L) if (matchTo[u] >= 0) // make explicit matching
    matching.push_back( Edge(u, matchTo[u], 1) );
  return match;
}

int gcd(int x, int y){
	return y?gcd(y, x%y):x;
}
int main(){
	int m, n;
	while(cin>>m>>n, m||n){
		vector<int> blue(m), red(n);
		rep(i, m)cin>>blue[i];
		rep(i, n)cin>>red[i];
		
		Graph g;
		Edges egs;
		rep(i, m){
			Edges es;
			rep(j, n){
				if(gcd(blue[i], red[j])==1)continue;
				Edge e(i, j+m, 1);
				es.push_back(e);
				egs.push_back(e);
			}
			g.push_back(es);
		}
		rep(i, n){
			Edges es;
			rep(j, m){
				if(gcd(red[i], blue[j])==1)continue;
				Edge e(i+m, j, 1);
				es.push_back(e);
				egs.push_back(e);
			}
			g.push_back(es);
		}
		cout<<bipartiteMatching(g, m, egs)<<endl;
	}
	return 0;
}

Measured memory_bytes: 6440
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define All(V) v.begin(), v.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
  string s;
  int n;
  cin >> s >> n;
  deque<char> dq;
  rep(i, s.size()){
    dq.push_back(s[i]);
  }
  int cnt = 0;
  rep(i, n){
    int a; cin >> a;
    if(a == 1){
      //reverse(dq.begin(), dq.end());
      cnt++;
    }
    else{
      int b;
      char c;
      cin >> b >> c;
      if(b == 1){
        if(cnt % 2 == 0){
          dq.push_front(c);
        }
        else dq.push_back(c);
      }
      else{
        if(cnt % 2 == 0)
          dq.push_back(c);
        else dq.push_front(c);
      }
    }
  }
  if(cnt % 2 == 0){
    for(auto itr = dq.begin(); itr != dq.end(); itr++){
      cout << *itr;
    }
  }
  else{
    reverse(dq.begin(), dq.end());
    for(auto itr = dq.begin(); itr != dq.end(); itr++){
      cout << *itr;
    }
  }
  cout << endl;
  system("pause");
}


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

int main() {
  int n;
  cin >> n;

  bool arr[4][14];
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 14; j++){
      arr[i][j] = 0;
    }
  }
  
  char c;
  int a, b;
  for (int i = 0; i < n; i++) {
    cin >> c >> b;

    if (c == 'S') a = 0;
    if (c == 'H') a = 1;
    if (c == 'C') a = 2;
    if (c == 'D') a = 3;

    arr[a][b] = 1;
  }

  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 14; j++) {
      if (arr[i][j] == 0) {
	if (j == 0) continue;
	else {
	  if (i == 0) c = 'S';
	  if (i == 1) c = 'H';
	  if (i == 2) c = 'C';
	  if (i == 3) c = 'D';
	cout << c << " " << j << endl;
	}
      }
    }
  }
  return 0;
}


Measured memory_bytes: 3012
#pragma GCC optimize("O3")
#pragma GCC target("avx")
#pragma GCC optimize("unroll-loops")
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define DB double
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define rep(i,n) FOR(i,0,n)
//#define MOD 1000000007
#define MOD 998244353
#define INF 1145141919810364364
#define PI 3.14159265358979
#define ERR 0.00000000000001
#define NUM 200010

void swap(LL* a,LL* b){LL tmp=*a;*a=*b;*b=tmp;}
void Yn(LL a){if(a)printf("Yes\n");else printf("No\n");}
void YN(LL a){if(a)printf("YES\n");else printf("NO\n");}
LL pwmn(LL a,LL n){LL ans=1;while(ans<a)ans*=n;return ans;}
LL GCD(LL a,LL b){LL c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
int lcmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return 1;if(*(LL*)a<*(LL*)b)return -1;return 0;}
int lcmpr(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return -1;if(*(LL*)a<*(LL*)b)return 1;return 0;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int ccmpr(const void* a,const void* b){return *(char*)b-*(char*)a;}
int scmp(const void* a,const void* b){return strcmp((char*)a,(char*)b);}
int scmpr(const void* a,const void* b){return strcmp((char*)b,(char*)a);}
LL mod(LL a,LL m){if(a<0)return a%m+m;else return a%m;}
LL DIV(LL a,LL d){LL m=MOD,x=1,y=0,k;while(m){k=d/m;d-=k*m;swap(&m,&d);x-=k*y;swap(&x,&y);}return mod(a*mod(x,MOD),MOD);}
LL FAC(LL a){LL i,ans=1;FOR(i,1,a+1){ans*=i;if(MOD>0&&ans>MOD)ans%=MOD;}return ans;}
LL POW(LL a,LL n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return ans;}
LL fact[NUM],finv[NUM],inv[NUM];
void comi(){LL i;fact[0]=fact[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fact[i]=fact[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
LL com(LL n,LL k){if(n<k||n<0||k<0)return 0;return fact[n]*(finv[k]*finv[n-k]%MOD)%MOD;}

int main(){
  LL A,B,ans=0,xa,na,xb,nb;
  scanf("%lld%lld",&A,&B);
  xa=A*125+124,na=A*125,xb=B*100+99,nb=B*100;
  ans=(MAX(na,nb)+9)/10;
  if(xa<nb||xb<na)ans=-1;

  printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 128
import sys
import math
input = lambda:sys.stdin.readline().strip()
n,m,q = map(int,input().split())
score = 0
def calc_score(arr):
    val = 0
    for i in qs:
        a,b,c,d = i 
        if arr[b-1]-arr[a-1]==c:
            val+=d
    return val
def f(i,ne,arr):
    if i==n:
        global score 
        score = max(score,calc_score(arr))
        return 
    for j in range(ne,m+1):
        arr = arr+[j]
        f(i+1,j,arr)
        arr.pop()
qs = []
for i in range(q):
    qs.append(list(map(int,input().split())))
f(0,1,[])
print(score)

Measured memory_bytes: 9232
//define DEBUG for debug
//#define DEBUG

#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair 
#define pb push_back
#define MAX 100000
#define MOD 1000000007
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll n,w;
pll arr[100+100];
ll dp[100+100][MAX+100];
ll dfs(ll i,ll wei){
	if(dp[i][wei] == 0){
		if(i <= n){
			if(wei+arr[i].F <= w)
				dp[i][wei] = dfs(i+1,wei+arr[i].F)+arr[i].S;
			dp[i][wei] = max(dp[i][wei],dfs(i+1,wei));
		}else
			return 0;
	}
	return dp[i][wei];
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef DEBUG
	freopen("i.txt","r",stdin);
	freopen("o.txt","w",stdout);
#endif
	cin >> n >> w;
	for(ll i = 0;i < n;i++)
		cin >> arr[i].F >> arr[i].S;
	cout << dfs(0,0);
	return 0;
}

Measured memory_bytes: 78080
from itertools import product
s = input()
A, B, C, D = int(s[0]), int(s[1]), int(s[2]), int(s[3])

P = product([1, -1], repeat=3)

def convert(integer):
    if integer == 1:
        return "+"
    elif integer == -1:
        return "-"

for o1, o2, o3 in P:
    if A + B * o1 + C * o2 + D * o3 == 7:
        print(str(A) + convert(o1) + str(B) + convert(o2) + str(C) + convert(o3) + str(D) + "=7")
        exit()

Measured memory_bytes: 9112
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 18
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n, m, p = LI()
G = [[] for _ in range(n)]
for i in range(m):
    a, b, c = LI()
    G[a - 1] += [(b - 1, c - p)]


def bellman_ford(G, start=0):
    n = len(G)
    costs = [-INF] * n
    costs[0] = 0
    v_nows = set([start])
    for _ in range(n):
        v_changeds = set()
        for u in v_nows:
            for v, c in G[u]:
                if costs[u] + c > costs[v]:
                    costs[v] = costs[u] + c
                    v_changeds.add(v)
        v_nows = v_changeds
    if not v_changeds:
        return costs[n - 1]

    for i in v_nows:
        costs[i] = -INF
    que = deque(v_nows)
    while que:
        u = que.popleft()
        for v, cost in G[u]:
            if costs[v] != -INF:
                costs[v] = -INF
                que += [v]
    return costs[n - 1]


cost = bellman_ford(G, 0)
if cost == -INF:
    print(-1)
else:
    print(max(0, cost))

Measured memory_bytes: 65116
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const long long INF=1LL << 60;
long long a,b;
long long dp[100200][110];
long long w[110],v[110];


int main(){
  int n;
  cin>>n;
  vector<int> vec(n);
  rep(i,n){
      cin>>vec.at(i);
  }
  int num=0;
  rep(i,n-1){
      int minj=i;
      for(int j=i;j<n;j++){
          if(vec.at(j)<vec.at(minj)){
              minj=j;
          }
      }
      if(i!=minj){
          num++;
      }
        int tes=vec.at(i);
        vec.at(i)=vec.at(minj);
        vec.at(minj)=tes;
        //num++;
        
      //} 
  }
  rep(i,n){
      cout<<vec.at(i);
      if(i!=n-1){
          cout<<" ";
      }
      else{
          cout<<endl;
      }
  }
  cout<<num<<endl;

}






Measured memory_bytes: 3076
#include <iostream>
#include <vector>
using namespace std;
using ull = long long;
constexpr ull mod = 1e9 + 7;

ull modinv(ull a)
{
    ull b = mod, u = 1, v = 0;
    while (b)
    {
        ull t = a / b;
        a -= t * b;
        b += a, a = b - a, b -= a;
        u -= t * v;
        v += u, u = v - u, v -= u;
    }
    u %= mod;
    if (u < 0)
        u += mod;
    return u;
}

ull comb(ull n, ull r)
{
    ull ret = 1;
    for (ull i = 1; i <= r; i++)
    {
        ret *= ((n - i + 1) * modinv(i)) % mod;
        ret %= mod;
    }
    return ret;
}

ull modpow(ull x, ull n)
{
    ull ret = 1;
    while (n > 0)
    {
        if (n & 1)
        {
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

int main()
{
    ull n, a, b;
    cin >> n >> a >> b;
    ull pow2 = modpow(2, n);
    ull tmp = ((comb(n, a) + comb(n, b)) % mod + 1) % mod;

    ull ans = pow2 - tmp;
    if (ans < 0)
        ans += mod;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>


using namespace std;

void c()
{
	int n;
	cin >> n;
	vector<int> d(n);
	for (int i = 0; i < n; i++) {
		cin >> d[i];
	}

	sort(d.begin(), d.end());

	int num = d[n / 2] - d[n / 2 - 1];
	cout << (num < 0 ? 0 : num) << endl;
}
int main()
{
	c();
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;
using pll=pair<ll,ll>;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define MOD 1000000007

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
	ll N;
	cin >> N;
	vector<ll> A(N);
	rep(i,N) {
		cin >> A[i];
	}
	rep(i,N) {
		if(A[i] == 0) {
			cout << 0 << endl;
			return 0;
		}
	}
	ll r = 1e18;
	ll ans = 1;
	rep(i,N) {
		ll temp = ans;
		temp *= A[i];
		if(temp > r || temp < 0 || temp < ans) {
			cout << -1 << endl;
			return 0;
		}
		ans = temp;
	}
	cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4052
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


void solve(void)
{
  
  int N,M;
  cin>>N>>M;
  vector<queue<int> > data(N);
  for (int i = 0; i < N; i++)
  {
    for (int j = 0; j < M; j++)
    {
      int X;
      cin>>X;
      data[i].push(X);
    }
  }
  set<int> SET;
  int ANS = INF;
  for (int r = 0; r < M; r++)
  {
    int OUT = -1;
    int MAX = 0;
    map<int,int>mp;
    mp.clear();
    for (int i = 0; i < N; i++)
    {
      while(SET.find(data[i].front()) != SET.end())
      {
        data[i].pop();
        // DEBUG("call");
      }
      mp[data[i].front()]++;
    }
    for (auto i : mp)
    {
      if(chmax(MAX,i.second))
      {
        OUT = i.first;
      }
    }
    chmin(ANS,MAX);
    SET.insert(OUT);

  }
  cout<<ANS<<endl;
  
  
  
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(15);
  solve();

  return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int A,B,C;
  cin >> A >> B >> C;
  
  if(A==7){
    if(B==5 && C==5){
      cout << "YES" << endl;
    }else{
      cout << "NO" << endl;
    }
  }else if(B==7){
    if(A==5 && C==5){
      cout << "YES" << endl;
    }else{
      cout << "NO" << endl;
    }
  }else if(C==7){
    if(B==5 && A==5){
      cout << "YES" << endl;
    }else{
      cout << "NO" << endl;
    }
  }else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>istream&operator >>(istream&is,vector<T>&vec){for(T&x:vec)is>>x;return is;}
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
template<class T>inline bool CHMIN(T&a,T b){if(a > b){a = b;return true;}return false;}
template<class T>inline bool CHMAX(T&a,T b){if(a < b){a = b;return true;}return false;}
constexpr int INF = 1e18;



signed main(){
	int x;
	cin >> x;
	out(x ^ 1);
}

Measured memory_bytes: 3624
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
void check(int h,int m)
{
	double v=abs(30.0*h-5.5*m);
	v=min(v,360-v);
	if(v<30)cout << "alert" << endl;
	else if(v<90)cout << "warning" << endl;
	else cout << "safe" << endl;
	return;
}
int main()
{
	int n;
	cin >> n;
	for(int i=0;i<n;i++)
	{
		string s;
		cin >> s;
		int h,m;
		h=(s[0]-'0')*10+(s[1]-'0');
		m=(s[3]-'0')*10+(s[4]-'0');
		check(h,m);
	}
	return 0;
}

Measured memory_bytes: 1196
N,W=map(int,input().split())
w=[0]*N
v=[0]*N

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

M=sum(v)
#i番目までの商品で価値の総和をjにしたときの重さ（W以下の範囲で）
dp=[[10**9]*(M+1) for _ in range(N+1)]

for i in range(N+1):
    dp[i][0]=0
    
ans=0
for i in range(1,N+1):
    for j in range(1,M+1):
        dp[i][j]=dp[i-1][j]
        if j-v[i-1]>=0:
            new=dp[i-1][j-v[i-1]]+w[i-1]
            if new<=W:
                dp[i][j]=min(dp[i][j] , new)
                ans=max(ans,j)

print(ans)

Measured memory_bytes: 119772
#include<iostream>
using namespace std;
int main(){
    int isfalse=0;
    char adad[4];
    cin>>adad;
    for(int i=0;i<3;i++){
        if(adad[i]==adad[i+1]){
            isfalse=1;
            break;
        }
    }
    if(isfalse==1){
        cout<<"Bad";
    }
    else{
        cout<<"Good";
    }
}


Measured memory_bytes: 3620
N=int(input())

a=[0]*N

for i in range(N):
  a[i]=int(input())
  
a.sort()
count=1
ans=[]

for i in range(N-1):
  if a[i]==a[i+1]:
    count+=1
  else:
    if count%2==1:
      ans.append(a[i])
    count=1
    
if count%2==1:
  ans.append(a[i])

print(len(ans))

Measured memory_bytes: 8100
#include<iostream>
#include<cstdio>
#include<algorithm>
	using namespace std;
int main()
{
	int s[5];
	scanf("%d %d %d",&s[1],&s[2],&s[3]);
	sort(s+1,s+3+1);
	printf("%d",(s[2]-s[1])+(s[3]-s[2]));
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>

int main()
{
  std::string a, b, c;
  std::cin >> a >> b >> c;

  std::string s;
  s.push_back( a[ 0 ] );
  s.push_back( b[ 0 ] );
  s.push_back( c[ 0 ] );

  std::transform( s.cbegin(), s.cend(), s.begin(), toupper );

  std::cout << s << std::endl;
  return 0;
}


Measured memory_bytes: 888
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
class JNum{
	static constexpr uint64_t mod = 1000000007;
	uint64_t num;
public:
	JNum(uint64_t x):num(x%mod){}
	JNum operator+(const JNum& j)const{
		return (num + j.num)%mod;
	}
	JNum operator*(const JNum& j)const{
		return (num * j.num)%mod;
	}
	void operator+=(const JNum& j){
		num += j.num;
		num %= mod;
	}
	void operator*=(const JNum& j){
		num *= j.num;
		num %=mod;
	}
	uint64_t out()const{return num;}
};

int main(void){
	int64_t x,y;
	std::cin >> x;
	std::cin >> y;
	if(std::abs(x - y)>=2)
		std::cout << "Alice"<<std::endl;
	else
		std::cout << "Brown"<<std::endl;
}

Measured memory_bytes: 256
line = gets.chomp.split.map(&:to_i)
a = line[0]
b = line[1]
k = line[2]

times = 0
ans = 0
i = a < b ? b : a
while i > 0 do
    if a % i == 0 and b % i == 0
        times += 1
        ans = i
    end
    break if times == k
    i -= 1
end

puts ans


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

int main(){
  int K;
  std::string S;
  std::string out;
  
  cin >> K;
  cin >> S;
  
  
  int leng = S.size();
  
  if(leng > K){
     out = S.substr(0,K) + "...";
  }
  else{
      out = S;
  }
  
  std::cout << out << std::endl;
}
  
  
  

Measured memory_bytes: 3612
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);


    public static void main(String[] args) {
        int n = sc.nextInt();
        int k = sc.nextInt();
        int count = 0;
        for (int i = 0; i < n; i++) {
            int x = sc.nextInt();
            count += Math.min(x, k - x) * 2;
        }
        System.out.println(count);
    }

}


Measured memory_bytes: 21844
// g++ macro.cpp -std=c++14
#include <bits/stdc++.h> //STL include
typedef long long ll;// long long int
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;//namespace

#define dump(x)  cout << #x << " = " << (x) << endl;// debug cout
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;

#define SANKOU(n,a,b) cout << ((n) ? (a) : (b) ) << endl;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)// for macro
#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 WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j]);// warshall-floyd

#define CIN(x) int x;cin>>x;
#define CIN2(x,y) int x,y;cin>>x>>y;
#define CIN3(x,y,z) int x,y,z;cin>>x>>y>>z;
#define SCIN(x) string x;cin>>x;
#define SCIN2(x,y) string x,y;cin>>x>>y;
#define COUT(x) cout<<(x)<<endl;
#define SCOUT(x) cout<<(x)<<" ";
#define ENDL cout<<endl;

#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_;
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i];
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl;

#define ALL(obj) (obj).begin(),(obj).end()// iterator

#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())


#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define L list<int>

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


int main(){
    CIN(n);V a(n);VECCIN(a);
    ll accu=accumulate(ALL(a),0LL);
    ll now=0;
    ll min_=LINF;
    REP(i,n-1){now+=a[i];accu-=a[i];min_=min(min_,abs(accu-now));}
    COUT(min_);

    return 0;
}


Measured memory_bytes: 1024
// author: gary
#include <bits/stdc++.h>
using namespace std;
#define SZ(x) ( (int) (x).size() )

long long A, B, C, D;
long long N;

int main() {
  cin >> A >> B >> C >> D >> N;

  C = min(C, min(4 * A, 2 * B));

  if(C * 2 < D) {
    cout << N * C << endl;
  } else {
    cout << ((N / 2) * D + (N % 2) * C) << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	char a1,b1,c1,d1;
	int ans,a,b,c,d;
	cin>>a1>>b1>>c1>>d1;
	a=a1-'0';
	b=b1-'0';
	c=c1-'0';
	d=d1-'0';
	for(char i='+'; i<='-'; i++)
		for(char j='+'; j<='-'; j++)
			for(char k='+'; k<='-'; k++) {
				ans=a;
				if(i=='+')ans+=b;
				else if(i=='-')ans-=b;
				if(j=='+')ans+=c;
				else if(j=='-')ans-=c;
				if(k=='+')ans+=d;
				else if(k=='-')ans-=d;
				if(ans==7) {
					cout<<a<<i<<b<<j<<c<<k<<d<<"="<<ans<<endl;
					return 0;
				}
			}


}

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

// プロセスを表す構造体
typedef struct pp {
  char name[100];
  int t;
} P;

// public変数の宣言
P Q[LEN];
int head, tail, n;

void enqueue(P x){
  Q[tail] = x;
  tail = (tail + 1) % LEN;
}

P dequeue(void){
  P x = Q[head];
  head = (head + 1) % LEN;
  return x;
}

int min (int a , int b){return a < b ? a : b ;}

int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d",&n,&q);

  for( i = 1; i <= n; i++){
    scanf("%s",Q[i].name);
    scanf("%d",&Q[i].t);
  }
  head = 1; tail = n+1;

  // シミュレーション
  while(head != tail){
    u = dequeue();
    c = min(q,u.t);
    u.t -= c;
    elaps += c;
    if ( u.t > 0) enqueue(u);
    else {
      printf("%s %d\n",u.name, elaps);
      }
    }

  return 0;
}



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


int main() {
    int N;
    string S;
    cin >> N >> S;
    vector<int> vecB(N + 1), vecW(N + 1) ,ans(N + 1);
    for (int i = 0; i < N; i++) {
        if (S[i] == '#') {
            vecB[i + 1] = vecB[i] + 1;
            }
        else{
            vecB[i + 1] = vecB[i];
        }
        if (S[N - 1 - i] == '.') {
            vecW[N - 1 - i] = vecW[N - i] + 1;
            }
        else{
            vecW[N - 1 - i] = vecW[N - i];
        }
    }
    for (int i = 0; i <= N; i++) {
        ans[i] = vecB[i] + vecW[i];
    }
    sort(ans.begin(),ans.end());
    cout << ans[0] << endl;


    return 0;
}


Measured memory_bytes: 2948
#include<bits/stdc++.h>
using namespace std;
using Int = long long;

int main(){
    Int N; cin >> N;
    vector<Int>v(N);
    using pi = pair<Int,Int>;
    vector<pi>ans;
    for(auto& e : v)
        cin >> e;
    auto itr = max_element(v.begin(),v.end(),[](Int a,Int b){
        return abs(a) < abs(b);
    });
    Int idx = distance(v.begin(), itr);
    if(*itr >= 0){
        for(Int i = 0; i < N; ++i){
            if(v[i] < 0){
                ans.emplace_back(idx,i);
            }
        }
        for(Int i = 0; i + 1 < N; ++i)
            ans.emplace_back(i, i + 1);
        
    } else {
        for(Int i = N - 1; i >= 0; --i)
            if(v[i] > 0)
                ans.emplace_back(idx,i);
        for(Int i = N - 1; i - 1>= 0; --i)
            ans.emplace_back(i,i - 1);
    }
    cout << ans.size() << endl;
    for(auto p : ans)
        cout << p.first + 1 << " " << p.second + 1 << endl;
}


Measured memory_bytes: 256
//Author- Vaibhav singh
//will be expert soon 
// *#####################################################################################*
#include<bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_multiset tree<long long , null_type,less_equal<long long >, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_set tree<long long , null_type,less<long long >, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
#define ll long long int
#define YES cout<<"YES"<<"\n";
#define NO cout<<"NO"<<"\n";
#define ld     long double
#define yes cout<<"yes"<<"\n";
#define no cout<<"no"<<"\n";
#define No cout<<"No"<<"\n";
#define Yes cout<<"Yes"<<"\n";
#define f(i,a) for(i=0;i<a;i++)
#define fo(i,a) for(i=1;i<=a;i++)
#define fa(i,a) for(auto i:a)
#define r(i,a) for(auto i=a.rbegin();i!=a.rend();i++)
#define en cout<<"\n";
#define ull unsigned long long int
#define o(x) cout<<x<<"\n";
#define o1(x) cout<<x<<" ";
#define pb push_back
#define F first
#define in insert
#define mp make_pair
#define S second
#define pre(n) cout<<fixed<<setprecision(n);
#define      gcd(a,b)    __gcd(a,b)
#define bs            binary_search
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define test ll t;cin>>t;while(t-->0)
const ll Mod = 998244353;
#define mod 1000000007
#define pi 3.14159265358979323846
#define re return 0;
// *#######################################################################################*
// *#########################################################################################*
    //      ll ans=0,b[5000005]={0},a[5000005],i,n,x=0;                
   //ll k,n,i;

    int main()
    {
    ll n;cin>>n;
    ll a[n],i;
    
    f(i,n)
    {
          cin>>a[i];
         //s.in(a[i]);          
    }
    ll p=*min_element(a,a+n);
          ll mn=1e18,s=0,j;
          for(j=-100;j<=100;j++)
          {
                f(i,n)
                {
                      s+=((abs(j-a[i]))*(abs(j-a[i])));
                }
                mn=min(mn,s);
                s=0;
          }
          
   o(mn)
    re
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,ss="" ; cin>>s ; int as=0 ;
    for(int i = 0 ; i < s.size() ; i++)
    {
        if(i%2) ss+='p' ;
        else ss+='g' ;
    }
    for(int i = 0 ; i < s.size() ; i++)
    {
        if(s[i]!=ss[i])
        {
            if(s[i]=='p') as-- ;
            else if(s[i]=='g') as++ ;
        }
    }
    cout<<as<<endl ;
}


Measured memory_bytes: 3744
#include <iostream>
#include <string>
#include <algorithm>
#include <stdlib.h>
#include <iomanip>
#include <vector>
#include <cmath>
#include <bits/stdc++.h>
using namespace std;
//typedef long long unsigned int ll;
typedef long long ll;
//typedef pair<ll, ll> edge;
//typedef tuple<ll, ll, ll> tp;
const ll INF = 1e18;
 
int main() {
  ll n;
  cin >> n;
  ll a[n];
  ll mi = INF;
  ll sum = 0;
  
  int flag1 = 0;
  for(int i=0; i<n; i++){
    cin >> a[i];
    mi = min(abs(a[i]), mi);
    sum += abs(a[i]);
    if(a[i] == 0) flag1 = 1;
  }
  
  if(flag1 == 1){
    cout << sum << endl;
    exit(0);
  }
  
  int flag2 = 1;
  for(int i=0; i<n-1; i++){
    if(a[i]*flag2 < 0) flag2 = -1;
    else flag2 = 1;
  }
  if (a[n-1]*flag2 < 0) cout << sum - 2*mi << endl;
  else cout << sum << endl;
  
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
 
int A, B;
  cin >> A >> B;
int cnt = 0;
int mann, senn, hyaku, juu, iti;  
  
  for(int i = A;i <= B;i++){
    mann = i / 10000 % 10; iti = i % 10;
    senn = i / 1000 % 10; juu = i / 10 % 10;
  if((mann == iti) && (senn == juu)) cnt++;  
  }
 
  cout << cnt << endl;
  
return 0;
  
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

  int a, b, c;
  cin >> a >> b >> c;
  const int x = a + b + 1;
  int ans = b + c;
  if (x < c)
    ans = b + x;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
//Write a program which calculates the cube of a given integer x.
extern "C"
{
#include <stdio.h>

#define CUBIC   (3)

    int calc(const int x, const int num);

    int main(void)
    {
        int x;
        int ans = 0;
        scanf("%d", &x);

        ans = calc(x, CUBIC);

        printf("%d\n", ans);

        return (0);
    }

    //Calc a cubic of x.
    int calc(const int x, const int num)
    {
        if (1 > num) {
            return 1;
        }

        return x * calc(x, (num - 1));
    }
}

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

using namespace std;

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

  int n, a, x, y;
  cin >> n;
  vector<vector<pair<int,int>>> edges(n), inedges(n);
  for (int i = 0; i < n; ++i) {
    cin >> a;
    while (a--) {
      cin >> x >> y;
      x--;
      edges[i].push_back({x, y});
      inedges[x].push_back({i, y});
    }
  }
  int res = 0;
  for (int t = 0; t < (1<<n); ++t) {
    vector<bool> honest(n, false);
    for (int u = 0; u < n; ++u) 
      if ((t&(1<<u)) > 0) 
        honest[u] = true;
    bool ok = true;
    for (int i = 0; i < n; ++i) 
      if (honest[i]) {
      for (auto &e : edges[i]) 
        if ((honest[e.first] && e.second == 0) || (!honest[e.first] && e.second == 1)) {
          ok = false;
          break;
        }
      for (auto &e : inedges[i]) 
        if ((honest[e.first] && e.second == 0)) {
          ok = false;
          break;
        }
      }
    if (ok) res = max(res, __builtin_popcount(t));
  }
  cout << res << endl;

  return 0;
}



Measured memory_bytes: 256