akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>

#define NIL NULL

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;

Node root;

Node treeMinimum(Node);
Node treeMaximum(Node);
Node treeSearch(Node, int);
Node treeSuccessor(Node);
void insert(int);
void treeDelete(Node);
void inorder(Node);
void preorder(Node);


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    }
    else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    }
    else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    else if( com[0] == 'd' ){
      scanf("%d",&x);
      treeDelete(treeSearch(root, x));
    }
  }
  return 0;
}

Node treeMinimum(Node x){
  while(x->left != NIL){
    x = x->left;
  }
  return x;
}

Node treeMaximum(Node x){
  while(x->right != NIL){
    x = x->right;
  }
  return x;
}

Node treeSuccessor(Node x){
  Node y;
  if(x->right != NIL) return treeMinimum(x->right);

  y = x->parent;
  while(y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }
  return y; 
}

Node treeSearch(Node u, int k){
  if(u == NIL || k == u->key) return u;
  if(k < u->key) return treeSearch(u->left,k);
  else return treeSearch(u->right,k);
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if(z->left == NIL || z->right == NIL) y = z;
  else y = treeSuccessor(z);

  if(y->left != NIL) x = y->left;
  else x = y->right;

  if(x != NIL) x->parent = y->parent;
  if(y->parent == NIL) root = x;
  else if(y == y->parent->left) y->parent->left = x;
  else y->parent->right = x;

  if(y != z) z->key = y->key;

}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;

  if(y == NIL) root = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;

}

void inorder(Node u){
  if(u != NIL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }
}
void preorder(Node u){
  if(u != NIL){
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
  }
}



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

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

int n,a[200010],b[200010];
double lb,ub;
vector <double> v;

int main()
{
	cin>>n;
	repn(i,n) cin>>a[i]>>b[i];
	repn(i,n) v.pb(a[i]);
	sort(v.begin(),v.end());
	if(n%2==1) lb=v[(n+1)/2-1];
	else lb=(v[n/2-1]+v[n/2])/2.0;
	v.clear();
	repn(i,n) v.pb(b[i]);
	sort(v.begin(),v.end());
	if(n%2==1) ub=v[(n+1)/2-1];
	else ub=(v[n/2-1]+v[n/2])/2.0;
	//cout<<lb<<' '<<ub<<endl;
	if(n%2==1) cout<<(int)(ub-lb+1)<<endl;
	else cout<<(int)((ub-lb)/0.5+1)<<endl;
	return 0;
}

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

using namespace std;

using llint = long long int;

int main() {
  llint n, ans = 0;
  cin >> n;
  
  llint prev = 0;
  for(int i = 0; i < n; i++) {
    llint ai;
    cin >> ai;
    llint d = prev - ai;
    if(d > 0) {
      ans += d;
      prev = ai + d;
    } else
      prev = ai;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3568
import java.util.*;
import static java.lang.System.*;
public class Main {
    public static void main(String[]$){
        Scanner sc = new Scanner(in);
        int n=sc.nextInt();
        int[] node=new int[n+1];
        //頂点1,2,3,...,n
        //探索済み→node[i]=-1,未探索→node[i]=0
        //0はジャマなのではじめから探索済みにしておく
        node[0]=-1;
        //各頂点iに対し、そことつながっている頂点j,k,...をbridge[i]=j,k....で表す
        ArrayList<Integer>[] bridge=new ArrayList[n+1];
        for (int i = 1; i <=n ; i++) {
            bridge[i]=new ArrayList<Integer>();
        }
        int m=sc.nextInt();
        int[] a=new int[m+1];
        int[] b=new int[m+1];
        for (int i = 1; i <=m ; i++) {
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
        }
        for(int i=1;i<=m;i++){
            bridge[a[i]].add(b[i]);
            bridge[b[i]].add(a[i]);
        }
        int ans=0;
        for (int i = 1; i <=m; i++) {
            //i番目の辺を削除
            bridge[a[i]].remove((Integer)b[i]);
            bridge[b[i]].remove((Integer)a[i]);
            //条件を満たすか確認、満たすなら++ans
            if(bfs(node,bridge))++ans;
            //i番目の辺を復元
            bridge[a[i]].add(b[i]);
            bridge[b[i]].add(a[i]);
        }
        out.println(ans);
    }
    //グラフをBFS
    static boolean bfs(int[] node,ArrayList[] x){
        Queue<Integer> q=new ArrayDeque<>();
        //未探索→探索済みの回数をカウント(新たに頂点を探索したら++sum)
        //つまり、sumは「探索することができた頂点の個数」である
        int n=node.length-1;
        //初期化
        for(int i=1;i<=n;i++){
            node[i]=0;
        }
        //もし全体が連結ならば最終的にsum==nとなるはず
        int sum=0;
        //頂点1から探索開始
        q.add(1);
        while(q.size()>0) {
            int tempnode = q.poll();
            //未探索かどうか判定
            if (node[tempnode] == 0) {
                //探索済みにする
                node[tempnode] = -1;
                ++sum;
                //隣接する頂点をQueueに入れる（BFSですね）
                for (Object k : x[tempnode]) {
                    q.add((Integer) k);
                }
            }
        }
        //グラフが非連結になっているかどうか判定（非連結になっていれば題意を満たします）
        return sum!=n;
    }
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
bool have[107];
bool ok(int x){
	return x < 0 || have[x] == false;
}
int main(){
	int x, n;
	cin >> x >> n;
	int a[n];
	for(int i = 0; i < n; i++){
		cin >> a[i];
		have[a[i]] = true;
	}
	for(int i = 0; ; i++){
		int x1 = x - i;
		int x2 = x + i;
		if(ok(x1)){
			cout << x1 << endl;
			return 0;
		}
		if(ok(x2)){
			cout << x2 << endl;
			return 0;
		}
	}
	return 0;
} 

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long inf = 1LL<<60;

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i,n) cin >> p[i];

    int min=p[0];

    int cnt=0;

    rep(i,n){
        if(min>=p[i]){
            cnt++;
            min = p[i];
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include<algorithm>
#include<vector>

using namespace std;
vector<int>v;
void print()
{
    int ans=0;
    for(auto it=v.begin();it!=v.end();it++)
    {
        if(ans!=0)cout<<" ";
        cout<<*it;
        ans++;
    }
    cout<<endl;
}
int main()
{
    int n;
    cin>>n;
    v.resize(n);
    int i,j,k;
    for(i=0;i<n;i++)
    {
        cin>>v[i];
    }

    if(prev_permutation(v.begin(),v.end())==0)
    {
        //cout<<endl;
        next_permutation(v.begin(),v.end());
        print();
    if(next_permutation(v.begin(),v.end())==0)
    {
        //cout<<endl;
    }
    else {
    print();
    }
    }

    else
    {
        print();
        next_permutation(v.begin(),v.end());
        print();
        if(next_permutation(v.begin(),v.end())==0)
        {

        }
        else
        {
            print();
        }
    }

    return 0;
}



Measured memory_bytes: 3108
from collections import deque

s=input()
S=[]
for i in range(len(s)):
    S.append(s[i])
S=deque(S)
q=int(input())
flag=False
for i in range(q):
    t=input()
    if t=='1':
        if flag:
            flag=False
        else:
            flag=True
    else:
        if t[2]=='1':
            if flag:
                S.append(t[4])
            else:
                S.appendleft(t[4])
        elif t[2]=='2':
            if flag:
                S.appendleft(t[4])
            else:
                S.append(t[4])

if flag:
    x=''.join(S)
    print(x[::-1])
else:
    print(''.join(S))

Measured memory_bytes: 8924
fn get_input() -> String {
    let mut word = String::new();
    std::io::stdin().read_line(&mut word).unwrap();
    word.trim().to_owned()
}

fn main() {
    let n:usize = get_input().parse().unwrap();
    let h:Vec<i64> = get_input().split_whitespace().map(|x| x.parse().unwrap()).collect();

    let mut dp = [0; 100010];
    dp[1] = i64::abs(h[0] - h[1]);

    for i in 2..n {
        dp[i] = std::cmp::min(dp[i - 2] + i64::abs(h[i] - h[i - 2]), dp[i - 1] + i64::abs(h[i] - h[i - 1]));
    }

    println!("{}", dp[n-1]);
}

Measured memory_bytes: 7164
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp make_pair
#define ERASE(v,i) (v).erase(remove(all(v),i),(v).end())
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(it,c) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define debug(x) cerr<<#x<<" = "<<(x)<<endl;
#define LINE cerr<<"LINE: "<<__LINE__<<endl;
inline int toInt(string s){int v;istringstream i(s);i>>v;return v;}
template<class T> inline string toString(T x){ostringstream o;o<<x;return o.str();}
template<class T> void pv(T a,T b){for(T it=a;it!=b;++it)cerr<<*it<<" ";cerr<<endl;}
const int INF = 1000000000;
const double EPS = 1e-10;

int main() {
	for(int N, M; cin >> N >> M, N || M;) {
		vector<int> route(N);
		vector<int> dice(M);
		rep(i,N) cin >> route[i];
		rep(i,M) cin >> dice[i];
		N--;
		int here = 0;
		int i = 0;
		while(here < N) {
			here += dice[i++];
			if(here >= N) break;
			here += route[here];
		}
		cout << i << endl;
	}
}

Measured memory_bytes: 0
num = gets.strip.to_i
a=Array.new(num,0)
maneger_nums = gets.strip.split(" ").map do |i|
  i.to_i
end
(num-1).times do |i|
  a[maneger_nums[i]-1]+=1
end

num.times do |i|
  puts a[i]
end


Measured memory_bytes: 35800
#include <bits/stdc++.h>
using namespace std;
//型に気を付けよう
//a=0x61=97 '0'=0x30=48
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long  ll;
typedef long double  ld;
typedef string str;
typedef pair<int,int> pairii;
typedef vector<int> veci;
const double pi=3.1415926535;
const ll  mod=1000000007;
//桁数指定　cout << fixed << setprecision(2)
int main() {
  int x;
  cin>>x;
  cout<<x+x*x+x*x*x<<endl;
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) (a).size() 
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,n) for(int i=1;i<=n;i++)
#define ford(i,n) for(int i=n;i>=0;i--) 
#define REP(i,a,n) for(int i=a;i<n;i++)
#define foreach(itr,c) for(__typeof((c).begin(),(c).end())itr=c.begin();itr!=c.end();itr++) 
#define fill(a,b) memset(a,b,sizeof(a))
#define re return
#define INF 1e9
#define LINF 1e18
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pi > vpi; 
ll mod=1000000007;
int main(){
	int n;
	cin>>n;
	ll a[n];
	ll sum[n];
	rep(i,n){
		cin>>a[i];
	} 
	fill(sum,0);
	for(int i=n-1;i>=0;i--){
		if(i==n-1){
			sum[i]=a[i]%mod;
		}
		else{
			sum[i]=(sum[i+1]+a[i])%mod;
		}
	}
	ll ans=0;
	rep(i,n-1){
		ans=(ans+a[i]*sum[i+1])%mod;
	}
	cout<<ans;
	re 0;
}

Measured memory_bytes: 6736
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N, a, ap = 0;

  std::cin >> N;

  bool valid[222222] = {0};

  valid[0] = true;

  for (int i = 0; i < N; i ++) {
    std::cin >> a;

    if (valid[a - 1]) {
      valid[a] = true;

      ap = a;
    }
  }

  std::cout << (ap ? N - ap : -1) << std::endl;
  
  return 0;
}


Measured memory_bytes: 640
/* ex4_1
   Acro  */

#include <stdio.h> 
int main(void){
    int tree_num,see_num,ans;
    scanf("%d %d",&tree_num,&see_num);
    if (tree_num % (2 * see_num + 1) == 0){
        /* 割り切れるとき */
        ans = tree_num / (2 * see_num + 1);
    }
    else{
        /* 型変換をして切り捨て */
        ans = tree_num / (2 * see_num + 1) + 1;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  string s, t, u;
  cin >> s >> t >> u;
  cout << "A" << t[0] << "C" << endl;
  return 0;
}

Measured memory_bytes: 3604
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>


using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
std::random_device rd;
std::mt19937 mt(rd());
constexpr int MOD = 1e9 + 7; constexpr int MAX = 200020;
const double pi = acos(-1); constexpr double EPS = 1e-8;
constexpr ll INF = 1e16;
typedef array<int, 3>arr3;


void solve() {
	int N, M, D; cin >> N >> M >> D;
	double ans = (double)(N - D) * 2 / (N*N)*(M - 1);
	if (D == 0)ans /= 2.0;
	cout << setprecision(20) << ans << endl;
}

signed main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
		solve();
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    string S ;
    cin >> S;
    int ans=0;
    rep(i,4){
        if(S.at(i)=='+'){
            ans++;
        }else{
            ans--;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <utility> // pair
#include <string>
#include <vector>
#define MAX_N 100001
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define REP(i, n) for(int i=0; i<n; i++)
#define RER(i, n) for(int i=n-1; i>=0; i--)
#define ALL(v) v.begin() v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int n;

signed main(){
    cin >> n;
    if(n/100 == n%10) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cassert>
#include <algorithm>    
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cstring>
#include <cmath>
#include <bitset>
#define pb push_back
#define mk make_pair
#define eb emplace_back
#define eps 1e-8
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
// #define int long long
using namespace std;

typedef long double ld;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef unsigned long long ull; 
typedef vector<int> vii;
typedef vector<long double> vd;
const int inf = 1e9;
const int M = 1e9 + 7;
//__int128

template <const int n> class linear_base {
public:
	bitset<n> base[n];
	bool insert(bitset<n> vec) {
  	for(int i = n - 1; i >= 0; --i) {
  		if(vec[i]) {
  			if(base[i][i]) {
  				vec ^= base[i];
  			} else {
  				base[i] = vec;
  				return 1;
  			}
  		}
  	}
  	return 0;
	}

	bitset<n> getmax() {
		bitset<n> res;
		for(int i = n - 1; i >= 0; --i) {
			if(res[i] == 0 && base[i][i] > 0) {
				res ^= base[i];
			}
		}
		return res;
	}

};


signed main()
{
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n;
  cin >> n;
  const int maxn = 1e5 + 5;
  bitset<64> a[maxn], sum;
  for(int i = 0; i < n; ++i) {
  	long long x;
  	cin >> x;
  	a[i] = x;
  	sum ^= a[i];
  }
  sum.flip();
  for(int i = 0; i < n; ++i) {
  	a[i] &= sum;
  }
  linear_base<64> s;
  for(int i = 0; i < n; ++i) {
  	s.insert(a[i]);
  }
  long long res = (s.getmax()).to_ullong();
  res *= 2;
  sum.flip();
  res += sum.to_ullong();
  cout << res << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);

    if(n==1&&m==2||n==2&&m==1)
        printf("3\n");
    else if(n==1&&m==3||n==3&&m==1)
        printf("2\n");
        else
            printf("1\n");


    return 0;


}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 2000000000
#define infLL 2000000000000000000
#define MAX 1000002
#define sf(a) scanf("%d", &a)
#define sfl(a) scanf("%lld", &a)
#define pf(a) printf("%d ", a)
#define pfl(a) printf("%lld\n", a)
#define Case(t) printf("Case %d: ", t)
#define pii pair<int, int>
#define MOD 1000000007
#define mod 998244353
#define PI acos(-1.0)
#define eps 1e-9
#define mem(a, b) memset(a, b, sizeof(a))
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

void solve()
{
    string s;
    cin>>s;
    map<char, int>mp;
    int n = s.size();
    for(int i = 0; i < n; i++)
        mp[s[i]]++;
    for(char ch = 'a'; ch <= 'z'; ch++)
    {
        if(mp[ch]%2)
        {
            cout<<"No"<<endl;
            return;
        }
    }
    cout<<"Yes"<<endl;
}

int main()
{
    FASTIO;
    solve();

    return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
 
int main(){

	int n,min,count=0;
    cin >> n;
    vector<int> a(n);
       
  	for(int i=0;i<n;i++){
    	cin >> a.at(i);
    } 
    min = a.at(0);
    for (int i=0;i<n;i++){
    	if(min >= a.at(i)){
        	min = a.at(i);
            count++;
        }
    }
    cout << count << endl;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  
  vector<int> s(M), c(M);
  for (int i=0; i<M; i++) {
    cin >> s[i] >> c[i];
  }
  
  for (int i=0; i<M; i++) {
    if (N > 1 && s[i] == 1 && c[i] == 0) {
      cout << -1 << endl;
      return 0;
    }
    for (int j=i+1; j<M; j++) {
      if (s[i] == s[j] && c[i] != c[j]) {
        cout << -1 << endl;
        return 0;
      }
    }
  }
  
  vector<int> ans(N, -1);
  for (int i=0; i<M; i++) {
    ans[s[i]-1] = c[i];
  }
  
  if (N != 1 && ans[0] == -1) ans[0] = 1;
  for (int i=0; i<N; i++) {
    cout << max(ans[i], 0);
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i ++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i ++)
#define MP make_pair

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int MOD = 998244353;

int main()
{
	int n;
	cin >> n;
	cout << 180 * (n - 2) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e9;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
//aoj 1163
struct edge{int to,cap,rev;};//ikisaki youryou gyakuhen
class MF{//max flow
	public:
	int n;
	vector<vector<edge> >G;//[MAX];
	vector<bool>used;//[MAX];
	MF(int size){
		n=size;
		G=vector<vector<edge> >(n);
	}
	void add_edge(int from, int to, int cap){
		edge q={to,cap,int(G[to].size())};
		G[from].push_back(q);
		q={from,0,int(G[from].size()-1)};
		G[to].push_back(q);
	}
	int dfs(int v,int t, int f) {
		if(v==t)return f;
		used[v]=1;
		for(int i=0;i<G[v].size();i++){
			edge &e=G[v][i];
			if(used[e.to]||e.cap<=0) continue;
			int d =dfs(e.to,t,min(f,e.cap));
			if(d>0){
				e.cap-=d;
				G[e.to][e.rev].cap+=d;
				return d;
			}
		}
		return 0;
	}
	int ford_fulkerson(int s,int t) {//from s to t
		int flow=0,f;
		while(1){
			used=vector<bool>(n,false);
			f=dfs(s,t,inf);
			if(f==0)return flow;
			flow+=f;
		}
	}
};
int gcd(int a,int b){
	if(a<b)swap(a,b);
	if(b==0)return a;
	return gcd(b,a%b);
}
int main(){
	int n,m;
	while(cin>>n>>m,n||m){
		vi a(n);
		vi b(m);
		MF mf(n+m+2);
		rep(i,n)cin>>a[i];
		rep(i,m)cin>>b[i];
		int s=n+m;int t=s+1;
		rep(i,n)rep(j,m)if(gcd(a[i],b[j])!=1)mf.add_edge(i,n+j,1);
		rep(i,n)mf.add_edge(s,i,1);
		rep(i,m)mf.add_edge(n+i,t,1);
		cout<<mf.ford_fulkerson(s,t)<<endl;
	}
}

Measured memory_bytes: 5592
#include <cstdio>
using namespace std;
int M,D,ans;
int main() {
    scanf("%d%d",&M,&D);
    for (int i = 22;i <= D;i++) {
        int d1 = i%10,d2 = i/10;
        if (d1 >= 2 && d2 >= 2 && d1*d2 <= M) ans++;
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 128
while True:
    n=[int(i) for i in input().split(" ")]
    if n==[0]:
        break
    for i in range(len(n)):
        if n[i]>10:
            n[i]=10
    one=n.count(1)
    score=sum(n)
    while score<=11 and one>0:
        if one>0:
            score+=10
            one-=1
    if score>21:
        score=0
    print(score)



Measured memory_bytes: 5604
N = int(input())
A = list(map(int, input().split()))
S = sum(A)
Ct = [0] * 100001
for i in A:
    Ct[i] += 1
Q = int(input())
for i in range(Q):
    B, C = map(int, input().split())
    S += (C - B) * Ct[B]
    Ct[C] += Ct[B]
    Ct[B] = 0
    print(S)


Measured memory_bytes: 20812
# https://atcoder.jp/contests/abc131/tasks/abc131_d

n = int(input())

work = []
for _ in range(n):
    a, b = map(int, input().split())
    work.append([a, b])

work.sort(key=lambda x: x[1])
for i in range(n - 1):
    work[i + 1][0] += work[i][0]

for i in range(n):
    if work[i][0] <= work[i][1]:
        continue
    else:
        print('No')
        break
else:
    print('Yes')

Measured memory_bytes: 84696
#include<bits/stdc++.h>
#include<atcoder/dsu>
#define pb push_back
#define mp make_pair
#define ii pair<int,int>
#define int long long
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0)
#define modulo 1000000007
using namespace std;
using namespace atcoder;

int32_t main(){
    fastio();
    int n,m,a,b;
    cin >> n >> m;
    dsu d(n);
    for(int i=0;i<m;i++){
        cin >> a >> b;
        d.merge(a-1,b-1);
    }
    cout << d.groups().size()-1;
}


Measured memory_bytes: 9004
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef pair<string , int> s_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
//#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
const int64 INF = 1LL << 58;
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 (a>b) { a=b; return 1; } return 0; }
template<typename T> void remove(T & vector, unsigned int index){vector.erase(vector.begin() + index);}

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

    int N, M; cin >> N >> M;
    vei x(M), y(M); rep(i,M) { cin >> x[i] >> y[i]; x[i]--; y[i]--; } //0-index

    veb mayin(N, false);
    vei in(N, 1);

    mayin[0] = true;

    rep(i,M) {
        if(mayin[ x[i] ]) { mayin[ y[i] ] = true; in[ y[i] ]++; }
        else { in[ x[i] ]--, in[ y[i] ]++; continue; }
        in[ x[i] ]--;
        if(in[ x[i] ] == 0) mayin[ x[i] ] = false;
    }

    int ans = 0;
    rep(i,N) if(mayin[i]) ans++;
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 1408
#include <iostream>
#include <locale>
#include <string>
#include <algorithm>
using namespace std;

int main() {
	string text;
	int n;
	
	cin >> text;
	cin >> n;
	
	for (int i=0; i < n; i++) {
		string command;
		int r,s;
		string rep;
		
		cin >> command >> r >> s;
		if (command == "replace") cin >> rep;
		
		if ( command == "replace" ) {
			text.replace(r,s-r+1,rep);
		}
		else if( command == "reverse" ) {
			string text2 = text;
			int j,k;
			for(j=s, k=r; j>=r; j--, k++) {
  				text2[k] = text[j]; 
 			}
			text = text2;
		}	
		else if ( command == "print" ) {
			cout << text.substr(r,s-r+1) << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3224
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned ll
#define PI acos(-1)
#define vi vector<int>
#define pi pair<int, int>
#define pl pair<ll, ll>
template<typename T> using v2 = vector<vector<T>>;
template<typename T> using v3 = vector<vector<vector<T>>>;
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
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; }
const int MOD = 1e9 + 7;
const int INF = 1e9 + 200;
const ll INFLL = 2e18 + 200;

int table[1000 * 1000 + 100];

void gen_table() {
    for (int i = 2; i <= 1000 * 1000; i++) {
        if (table[i] != 0) continue;
        for (int j = i + i; j <= 1000 * 1000; j += i) table[j] = i;
    }
}

set<int> prime_factor(int tmp) {
    set<int> ret;
    while (true) {
        if (table[tmp] == 0) {
            ret.insert(tmp);
            break;
        }
        ret.insert(table[tmp]);
        tmp /= table[tmp];
    }
    return ret;
}

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    cin >> A;
    sort(A.begin(), A.end());
    gen_table();
    map<int, int> check;
    for (auto tmp : A) {
        if (tmp == 1) continue;
        set<int> prime = prime_factor(tmp);
        for (auto num : prime) check[num]++;
    }
    bool pairwise = true;
    for (auto tmp : A) {
        if (tmp == 1) continue;
        set<int> prime = prime_factor(tmp);
        for (auto num : prime) {
            if (check[num] > 1) pairwise = false;
            check[num]--;
        }
    }
    int tmp = A[0];
    for (int i = 1; i < N; i++) tmp = gcd(tmp, A[i]);
    bool setwise = (tmp == 1);
    if (pairwise) {
        cout << "pairwise coprime" << endl;
    } else if (setwise) {
        cout << "setwise coprime" << endl;
    } else {
        cout << "not coprime" << endl;
    }
} 

Measured memory_bytes: 14644
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<long long> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  long long ans = 0;
  for(int i = 0; i < n-1; i++){
    if(a[i] > a[i+1]){
      ans = ans + a[i] - a[i+1];
      a[i+1] = a[i];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 4756
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        // 入力
        long n = long.Parse(Console.ReadLine());

        // n < rのk乗の最小値を求める
        long ans = (n+1)/2;
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define make_unique(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define Sort(vec) sort(vec.begin(),vec.end())
#define RSort(vec) sort(vec.rbegin(),vec.rend())
#define endl "\n"
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define vvi vector<vector<int> > 
#define vvl vector<vector<ll> >
#define all(st) st.begin(),st.end()
#define vpl vector<pair<ll,ll> >
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<ll,ll>
#define al vector<list<int> >
#define vs vector<string>
#define vb vector<bool>
#define vi vector<int>
#define vl vector<ll>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define ull unsigned long long int
#define eb emplace_back
#define pb push_back
#define ll long long int
#define minf -9223372036854775807
#define inf 9223372036854775807
#define f first
#define se second
#define mod 1000000007
#define mx 100001
using namespace std;
ll mi(ll n,ll m){ll pw=n%m;ll ex=m-2;ll ans=1;while(ex){if(ex&1) ans = ans*pw%m;pw = pw*pw%m;ex>>=1;}return ans%mod;}
ll pw(ll a,ll n){ll pw=a%mod;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw%mod;pw = pw*pw%mod;ex>>=1;}return ans%mod;}
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
void show(ll x){cout<<x<<" ";}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll Abs(ll x){return x>0?x:(-x);}
ll Ceil(ll a,ll b){return a/b+(a%b!=0);}
#define to_low(s) for_each(s.begin(), s.end(), [](char & c) {c = ::tolower(c);})
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define mkp make_pair
//#define d double
void solve(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	set<int> st[26];
	for(int i=0;i<n;i++) st[s[i]-'a'].insert(i);
	int q;
	cin>>q;
	while(q--){
		int a;cin>>a;
		if(a==1){
			int i;char c;cin>>i>>c;i--;
			st[s[i]-'a'].erase(i);
			st[c-'a'].insert(i);
			s[i]=c;
		}
		else{
			int l,r;cin>>l>>r;
			l--;r--;
			ll ans=0;
			for(int i=0;i<26;i++){
				auto it=st[i].lb(l);
				if(it!=st[i].end() && *it<=r) ans++;
			}
			cout<<ans<<endl;
		}
	}
	
	
	
	
}
int32_t main(){
FIO;
int t=1;
//cin>>t;
while(t--){
	solve();
}
}

Measured memory_bytes: 26268
#include<bits/stdc++.h>
using namespace std;
const int N=4e3+5;
int n,k,a[N][N],b[N][N];
int getsuma(int x,int y)
{
    if(x<0||y<0) return 0;
    return a[x][y];
}
int getsumb(int x,int y)
{
    if(x<0||y<0) return 0;
    return b[x][y];
}
int querya(int x1,int y1,int x2,int y2)
{
    return getsuma(x2,y2)-getsuma(x2,y1-1)-getsuma(x1-1,y2)+getsuma(x1-1,y1-1);
}
int queryb(int x1,int y1,int x2,int y2)
{
    return getsumb(x2,y2)-getsumb(x2,y1-1)-getsumb(x1-1,y2)+getsumb(x1-1,y1-1);
}
int solve(int sx,int sy,int c)
{
    int ans=0;
    if(c)
    {
        ans+=querya(sx+0,sy+0,sx+k-1,sy+k-1);
        ans+=querya(sx+k,sy+k,sx+2*k-1,sy+2*k-1);
        ans+=queryb(sx+0,sy+k,sx+k-1,sy+2*k-1);
        ans+=queryb(sx+k,sy+0,sx+2*k-1,sy+k-1);
    }
    else
    {
        ans+=queryb(sx+0,sy+0,sx+k-1,sy+k-1);
        ans+=queryb(sx+k,sy+k,sx+2*k-1,sy+2*k-1);
        ans+=querya(sx+0,sy+k,sx+k-1,sy+2*k-1);
        ans+=querya(sx+k,sy+0,sx+2*k-1,sy+k-1);
    }
    return ans;
}
int main()
{
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)
    {
        int x,y;char z;scanf("%d %d %c",&x,&y,&z);
        x%=(2*k);y%=(2*k);
        if(z=='B') a[x][y]++;
        else b[x][y]++;
    }
    for(int i=0;i<2*k;i++)
        for(int j=0;j<2*k;j++)
    {
        a[i+2*k][j+2*k]=a[i+2*k][j]=a[i][j+2*k]=a[i][j];
        b[i+2*k][j+2*k]=b[i+2*k][j]=b[i][j+2*k]=b[i][j];
    }
    for(int i=0;i<4*k;i++)
        for(int j=1;j<4*k;j++)
        a[i][j]+=a[i][j-1],b[i][j]+=b[i][j-1];
    for(int i=1;i<4*k;i++)
        for(int j=0;j<4*k;j++)
        a[i][j]+=a[i-1][j],b[i][j]+=b[i-1][j];
    int ans=0;
    for(int i=0;i<k;i++)
        for(int j=0;j<k;j++)
    {
        ans=max(ans,solve(i,j,0));
        ans=max(ans,solve(i,j,1));
    }
    printf("%d\n",ans);
}


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

typedef long long int LL;
typedef long long int LLint;
typedef pair<int,int> intpair;
typedef pair<bool,bool> boolpair;
typedef pair<string,string> strpair;
typedef pair<LL,LL> LLpair;
typedef pair<double,double> doublepair;
typedef pair<float,float> floatpair;
typedef vector<int> intvector;
typedef vector<bool> boolvector;
typedef vector<string> strvector;
typedef vector<LL> LLvector;
typedef vector<double> doublevector;
typedef vector<float> floatvector;
#define wait(sec) usleep((sec) * 1000000)
#define ED return 0;
#define TEST cout << "OK" << endl;
#define UP(a,b) ((a+(b-1))/b)
#define SORT(vec) sort(vec.begin(),vec.end());
#define DOUBLECHANGE(count) cout << setprecision(count);
#define REV(vec) reverse(vec.begin(),vec.end());
#define ipow(x,y) LL(pow(x,y))
#define INF 999999999
const long long mod = 1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> A (N);
    vector<int> B (N);
    for(int i = 0;i < N;i++){
        cin >> A[i] >> B[i];
    }
    REV(A);
    REV(B);
    long long int change = 0;
    for(int i = 0;i < N;i++){
//        cout << i+1 << " = " << (B[i]-(A[i]+change)%B[i])%B[i] << "(" << A[i]+change << ")" << endl;
        change += (B[i]-(A[i]+change)%B[i])%B[i];
    }
    cout << change << endl;
}


Measured memory_bytes: 1024
A,B=map(int,input().split())
A_list=[]
B_list=[]
for i in range(1201):
    if int(i*0.08)==A:
        A_list.append(i)
    if int(i*0.1)==B:
        B_list.append(i)
flg=0
for i in A_list:
    if i in B_list:
        print(i)
        flg=1
        break
if flg==0:
    print('-1')

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

using namespace std;
using ll = long long;
using ld = long double;
using Vec = vector<int>;


int main() {

    int n;
    cin>>n;
    n=n%10;
    if(n==3){
        cout<<"bon"<<endl;
    }
    else if(n==0||n==1||n==6||n==8){
        cout<<"pon"<<endl;
    }
    else{
        cout<<"hon"<<endl;
    }
 
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
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; }
typedef long long ll;
typedef pair<ll,ll> pint;
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b==0){
        return a;
    }
    else{
        return gcd(b,a%b);
    }
}
ll n,m,q;
vector<ll> a,b,c,d;
ll res=0;
void dfs(vector<int> ans){
    if(ans.size()==n){
        ll temp=0;
        rep(i,q)if(ans[b[i]-1]-ans[a[i]-1]==c[i]) temp+=d[i];
        chmax(res,temp);
        return ;
    }
    REP(i,ans.back(),m+1){
        ans.push_back(i);
        dfs(ans);
        ans.pop_back();
    }
    return;
}

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


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
 
int main(){
  int N;
  cin >> N;
 
  deque<int> deq;
 
  for(int i = 0; i < N; i++){
    int a;
    cin >> a;
    if(i % 2 == N % 2){
      deq.push_back(a);
    }
    else{
      deq.push_front(a);
    }
  }
 
  for(int i = 0; i < N; i++){
    if(i == 0){
      cout << deq[i];
    }
    else{
      cout << " " << deq[i];
    }
  }
 
  return 0;
}

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

const long long INF = 100100100100;

int main() {
    int A, B, Q;
    cin >> A >> B >> Q;
    vector<long long> s(A + 2), t(B + 2), x(Q);
    s[0] = -INF;
    s[A + 1] = INF;
    t[0] = -INF;
    t[B + 1] = INF;
    rep(i, A) cin >> s[i + 1];
    rep(i, B) cin >> t[i + 1];
    rep(i, Q) cin >> x[i];
    
    rep(i, Q) {
        auto s_iter1 = upper_bound(s.begin(), s.end(), x[i]);
        auto s_iter0 = s_iter1 - 1;
        auto t_iter1 = upper_bound(t.begin(), t.end(), *s_iter0);
        auto t_iter0 = t_iter1 - 1;
        auto t_iter3 = upper_bound(t.begin(), t.end(), *s_iter1);
        auto t_iter2 = t_iter3 - 1;
        long long s_0 = min(abs(*s_iter0 - *t_iter0), abs(*s_iter0 - *t_iter1));
        long long s_1 = min(abs(*s_iter1 - *t_iter2), abs(*s_iter1 - *t_iter3));
        long long tj = min(abs(x[i] - *s_iter0) + s_0, abs(x[i] - *s_iter1) + s_1);
        //変数名使い回し（よくない）
        s_iter1 = upper_bound(t.begin(), t.end(), x[i]);
        s_iter0 = s_iter1 - 1;
        t_iter1 = upper_bound(s.begin(), s.end(), *s_iter0);
        t_iter0 = t_iter1 - 1;
        t_iter3 = upper_bound(s.begin(), s.end(), *s_iter1);
        t_iter2 = t_iter3 - 1;
        s_0 = min(abs(*s_iter0 - *t_iter0), abs(*s_iter0 - *t_iter1));
        s_1 = min(abs(*s_iter1 - *t_iter2), abs(*s_iter1 - *t_iter3));
        long long jt = min(abs(x[i] - *s_iter0) + s_0, abs(x[i] - *s_iter1) + s_1);
        cout << min(jt, tj) << endl;
    }
}


Measured memory_bytes: 3712
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<bitset>
#include<map>

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long LL;
typedef double db;

int get(){
	char ch;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	if (ch=='-'){
		int s=0;
		while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
		return -s;
	}
	int s=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
	return s;
}

const int N = 1005;
const int mo = 1e+9+7;

int n,m;
LL k;
char mp[N][N];
struct matrix{
	LL a[2][2];
	LL* operator[](int x){return a[x];}
}ans,trs;

matrix operator *(matrix a,matrix b){
	matrix c;
	c[0][0]=c[0][1]=c[1][0]=c[1][1]=0;
	c[0][0]=(1ll*a[0][0]*b[0][0]+1ll*a[0][1]*b[1][0])%mo;
	c[0][1]=(1ll*a[0][0]*b[0][1]+1ll*a[0][1]*b[1][1])%mo;
	c[1][0]=(1ll*a[1][0]*b[0][0]+1ll*a[1][1]*b[1][0])%mo;
	c[1][1]=(1ll*a[1][0]*b[0][1]+1ll*a[1][1]*b[1][1])%mo;
	return c;
}

int main(){
	n=get();m=get();
	scanf("%lld",&k);
	fo(i,1,n)scanf("%s",mp[i]+1);
	int cnth=0,cntw=0;
	fo(i,1,n)if(mp[i][1]=='#'&&mp[i][m]=='#')cntw++;
	fo(i,1,m)if(mp[1][i]=='#'&&mp[n][i]=='#')cnth++;
	if ((cntw&&cnth)||k<2)return printf("1\n"),0;
	int val1=0,val2=0,val3=0;
	k-=2;
	if (cntw){
		fo(i,1,n)
			fo(j,1,m)
			if (mp[i][j]=='#'){
				val1++;
				if (mp[i][j-1]=='#')val2++;
				else val3++;
			}
		trs[1][1]=cntw;
	}
	else{
		fo(i,1,n)
			fo(j,1,m)
			if (mp[i][j]=='#'){
				val1++;
				if (mp[i-1][j]=='#')val2++;
				else val3++;
			}
		trs[1][1]=cnth;
	}
	if (!cntw&&!cnth){
		k++;
		LL ans=1,x=val1;
		for(;k;k/=2,x=x*x%mo)
		if (k&1)ans=ans*x%mo;
		return printf("%lld\n",ans),0;
	}
	ans[0][0]=1;ans[0][1]=0;
	trs[0][0]=val1;trs[0][1]=val2;
	for(;k;k/=2,trs=trs*trs)
	if (k&1)ans=ans*trs;
	LL fans=(1ll*ans[0][0]*val3%mo+mo-1ll*ans[0][1]*(cnth+cntw)%mo)%mo;
	printf("%lld\n",fans);
	return 0;
}

Measured memory_bytes: 1280
n = int(input())
s = sorted([input() for i in range(n)])
c = [1]*n

for i in range(n-1):
    if s[i] == s[i+1]:
        c[i+1] += c[i]
m = max(c)

for i in range(n):
    if c[i] == m:
        print(s[i])


Measured memory_bytes: 24744
#include <iostream>
using namespace std;
 //Compiler version g++ 6.3.0

 int main()
 {
 	int a;
 	cin >> a;
 	if(a==1||a==2||a==3||a==5||a==6||a==9||a==10||a==13||a==17){
 		cout << "No" << endl;
 	}else{
 		cout << "Yes" << endl;
 	}
 }

Measured memory_bytes: 256
#!/usr/bin/env python3

s = input()
srev = s[::-1]
subs = s[:(len(s)-1)//2]
subsrev = subs[::-1]
subs2 = s[(len(s)+3)//2-1:len(s)]
subs2rev = subs2[::-1]

for i in range(len(s)):
    if s[i] != srev[i]:
        print('No')
        exit(0)
for i in range(len(subs)):
    if subs[i] != subsrev[i]:
        print('No')
        exit(0)
for i in range(len(subs2)):
    if subs2[i] != subs2rev[i]:
        print('No')
        exit(0)
print('Yes')


Measured memory_bytes: 3064
// 20
/****************************************************
https://searleser97.gitlab.io/algorithms/template.cpp
****************************************************/

#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define forr(_, x, n) for (int _ = x; _ > n; _--)
#define fos(_, x, n, s) for (int _ = x; _ < n; _ += s)
#define forn(_, x, n) fos(_, x, n, 1)
#define rep(_, n) forn(_, 0, n)
#define fi first
#define se second
#define pb push_back
#define pairii pair<int, int>
#define all(x) x.begin(), x.end()
#define cerr(s) cerr << "\033[48;5;196m\033[38;5;15m" << s << "\033[0m"
// typedef __int128_t lli;
typedef long long int li;
typedef long double ld;
// 12

int sign(li x) { return x < 0 ? -1 : x > 0; }

//         a / b
li ceil(li a, li b) {
  if (sign(a) == sign(b) && a % b) return a / b + 1;
  else return a / b;
}

void _main(int tc) {
  int n;
  cin >> n;
  li sumt = 0, suma = 0;
  rep(i, n) {
    li t, a;
    cin >> t >> a;
    if (i == 0) sumt = t, suma = a;
    else {
      li m1 = ceil(sumt, t);
      li m2 = ceil(suma , a);
      li multi = max(m1, m2);
      sumt = t * multi, suma = a * multi;
    }
  }

  cout << sumt + suma << endl;
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  _main(0); return 0;
  int tc;
  cin >> tc;
  rep(i, tc) _main(i + 1);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long int
#define pll pair<int,int>
#define dbl long double
#define ff first
#define ss second
#define endl "\n"
#define mod 1000000007
#define eps 0.00000001
#define inf 1000000000000000001
#define all(x) (x).begin(),(x).end()
#define size(x) (int)(x).size()
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define popb() pop_back()
#define popf() pop_front()
#define mp(x,y) make_pair((x),(y))
#define vec(dt) vector<dt>
#define vv(dt) vector<vector<dt>>
#define fastio(x) ios_base::sync_with_stdio(x); cin.tie(NULL)
#define init(v,s) memset(v,s,sizeof(v)) 
#define bug(x) cerr<<"LINE: "<<__LINE__<<" || click to see test details "<<#x<<" = "<<x<<endl
#define loop(i,s,n) for(auto i=s;i<n;i++)
using namespace std;



signed main()
{
	fastio(0);
	int n,m;
	cin>>n>>m;
	int a[n];
	loop(i,0,n) cin>>a[i];
	int sum = 0,ans = 0;
	loop(i,0,n) sum += a[i];
	loop(i,0,n)
		if(a[i]>=(dbl)sum/(4.00*m)) ans++;
	if(ans>=m) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;		
} 

Measured memory_bytes: 256
#include<stdio.h>
#include<ctype.h>
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
int main(void){
    while(1){
        int map[9][9]={0};
        char s[102]={0};
        fgets(s,100,stdin);
        //printf("%s",s);
        if(s[0]=='#') break;
        int a,b,c,d;
        scanf("%d%d%d%d",&a,&b,&c,&d);
        //getchar()注意
        getchar();
        int y=0,x=0;
        int h=0,w=0;
        int p=0;
        while(1){
            if(isdigit(s[p])){
                rep(i,(s[p]-'0')){
                    map[y][x]=0;
                    if(h<y) h=y;
                    if(w<x) w=x;
                    x++;
                }
                p++;
            }
            else if(s[p]=='b'){
                map[y][x]=1;
                if(h<y) h=y;
                if(w<x) w=x;
                x++;
                p++;
            }
            else if(s[p]=='/'){
                y++; x=0;
                p++;
            }
            else{
                break;
            }
        }
        map[a-1][b-1]=0; map[c-1][d-1]=1;
        /*rep(i,h+1){
            rep(j,w+1){
                printf("%2d ",map[i][j]);
            }puts("");
        }puts("");*/
        p=0;
        rep(i,h+1){
            while(1){
                if(map[i][p]==1){
                    printf("b");
                    p++;
                }
                else if(map[i][p]==0){
                    int cnt=0;
                    while(1){
                        cnt++;
                        if(p==w||map[i][p+1]==1) break;
                        p++;
                    }p++;
                    printf("%d",cnt);
                }
                if(p>w){
                    if(i!=h)
                    printf("/");
                    p=0; break;
                }
            }
        }puts("");
    }
}



Measured memory_bytes: 2044
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
//const ll MOD=998244353;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

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



int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  // cout << fixed << setprecision(15);

  ll N; cin>>N;
  
  vector<ll> vec(0);
  function<void(ll,ll)> make=[&](ll i,ll S){
    ll sS=S;
    vector<int> judge={0,0,0};
    while(sS>0){
      if(sS%10==3) judge[0]=1;
      if(sS%10==5) judge[1]=1;
      if(sS%10==7) judge[2]=1;
      sS/=10;
    }
    int hoge=1;
    for(auto v:judge) if(!v) hoge=0;
    if(hoge) vec.push_back(S);
    if(i==9LL) return;
    make(i+1,S*10+3LL);
    make(i+1,S*10+5LL);
    make(i+1,S*10+7LL);
    
    return;
  };
  make(1LL,3LL); make(1LL,5LL); make(1LL,7LL);
  sort(vec.begin(),vec.end());
  //for(auto v:vec) cout<<v<<endl;
  ll ok=-1,ng=vec.size();
  while(abs(ok-ng)>1LL){
    ll mid=(ok+ng)/2LL;
    if(vec[mid]<=N) ok=mid;
    else ng=mid;
  }
  
  cout<<ok-(-1)<<endl;
  
  return 0;
}

Measured memory_bytes: 3788
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using BigInt = long long;
#define ALL(a)  (a).begin(),(a).end()
const long long INF = 1LL << 60;
const int MOD = 1000000007;

int main(){
    long long X;
    cin >> X;
    long long money = 100;
    for(int i = 1; i < INF; i++){
        money *= 1.01;
        if (money >= X){
            cout << i << endl;
            break;
        }
    }
}


Measured memory_bytes: 3588