akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <tuple>

using namespace std;



int main(){
    int N;
    cin >> N;
    long long A[N];
    for(int i = 0; i <N; i++){
        cin >> A[i];
    }

    sort(A,A+N);

    long long now = 1000000007;
    vector<long long> result;

    for(int i = 0; i < N; i++){
        if(now == A[i]){
            result.pop_back();
            now = 1000000007;
        }else{
            result.push_back(A[i]);
            now = A[i];
        }
    }

    cout << result.size() << endl;

    return 0;
}


Measured memory_bytes: 2168
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    for(int i=s.size()-2;i>=0;i--){
        int c=0;
        for(int j=0;j<i/2;j++){
            if(i%2==1){
                break;
            }
            if(s[j]==s[j+i/2])
                c++;
        }
        if(i/2==c){
            cout<<i<<endl;
            return(0);
        }
    }
    return(0);
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main (){
    int N;
    cin >> N;

    int ans=N;
    for(int a=1;a<N/2+1;a++){
        int dsa=0,dsb=0;
        int x=a,y=N-a;

        while(x!=0){
            dsa += x%10;
            x = x/10;
        }

        while(y!=0){
            dsb += y%10;
            y = y/10;
        }

        if(dsa+dsb<ans)ans=dsa+dsb;

    }

    cout << ans << endl;
}

Measured memory_bytes: 3620
S = input()
T = input()

length = len(S)

a = []
for i in range(length):
    a.append(S[i])

b = []
for i in range(length):
    b.append(T[i])

c = []
temp = []
for i in range(length):
    if a == b:
        print('Yes')
        break
    else:
        temp = [a[length-1]]
        c = temp + a[0:(length-1)]
        a = c
    if i == length - 1:
        print('No') 

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

int main() {

	int n;
	cin >> n;

	int sum=0;
	int cnt=0;

	rep(ncnt,n+1){
	rep (i,100){
		rep(j,100){
			if (j > i) break;
			rep(k,100){
				if (k > j) break;
				sum = i*i+j*j+k*k+i*j+j*k+k*i;
				if(ncnt==sum)
				{
					//cout << i << "," << j << "," << k << "       ";
					if ((i == j) && (j== k)) cnt ++;
					else if ((i == j) or (j == k)) cnt += 3;
					else if ((i != j) or ( j != k)) cnt += 6;
					//else cout << "count　できていないものあり" << endl;
				}
			}
		}
	}
	//if (cnt > 0) cout << ncnt << ":cnt" << cnt <<  endl;
	cout << cnt <<  endl;
	cnt =0;
	}
}

Measured memory_bytes: 3592
import sys
def solve():
    N, K = map(int, input().split())
    MOD = 10**9 + 7

    U = []; V = []
    for x in range(1, int(N**.5)+1):
        U.append(x)
        if x < N//x:
            V.append(N//x)
    V.reverse(); U.extend(V)

    L = len(U)
    prv = 0
    R = []
    for x in U:
        R.append(x-prv)
        prv = x
    def gen(R, S):
        r = 0
        for p, s in zip(R, S):
            r = (p * s + r) % MOD
            yield r

    S = [1]*(L+1)
    S[-1] = 0
    for k in range(K):
        S[L-1::-1] = gen(R, S)
    print(S[0])
solve()

Measured memory_bytes: 11820
#include <iostream>
using namespace std;
int main(void){
    int n;
    cin>>n;
    int s[n];
    int sum=0;
    int min=2e9;
    
    for(int i=0;i<n;i++){
        cin>>s[i];
        sum+=s[i];
        if(s[i]%10!=0&&min>s[i])min=s[i];
    }
    
    if(sum%10!=0){
        cout<<sum<<endl;
        return 0;
    }else{
        if((sum-min)%10!=0){
            cout<<sum-min<<endl;
            return 0;
        }else{
            cout<<"0"<<endl;
            return 0;
        }
    }
}


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

int main() {
    int count, A[1000];
    cin >> count;
    for (int i = 0; i < count; i++) {
        cin >> A[i];
    }
   
    for (int i = 0; i < count; i++) {
        int v = A[i];
        int j = i - 1;
        while (j >= 0 && A[j] > v) {
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = v;

        for (int j = 0; j < count; j++) {
            if (j > 0) cout << " ";
            cout << A[j];
        }
        cout << endl;
    }
}

Measured memory_bytes: 1164
'use strict'
// inputに入力データ全体が入る
function Main(input) {
  let inAry = input.split(" ");
  let a = inAry[0];
  let b = inAry[1];
  let k = inAry[2];

  let ayaku = [];
  let byaku = [];
  for(let i = 1; i <= a; i++){
    if(a % i === 0){
      ayaku.push(i);
    }
  }
  for(let i = 1; i <= b; i++){
    if(b % i === 0){
      byaku.push(i);
    }
  }


  let kouyakusu = ayaku.filter((value)=>{
    return byaku.indexOf(value) >= 0;
  })

  kouyakusu = byaku.filter((value)=>{
    return ayaku.indexOf(value) >= 0;
  })

  kouyakusu.sort((a, b) => {
    return a - b;
  });
  console.log(kouyakusu[kouyakusu.length - k]);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i


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

lr = []
for i in range(Q):
    l, r = map(int, input().split())
    lr.append([l, r, i])

lr.sort(key=lambda x: x[1])
# print("lr", lr)
rightest = [-1] * (N + 1)
current_q = 0
bit = Bit(N)
ans = [0] * Q

for i in range(N):
    if rightest[c[i]] != -1:
        bit.add(rightest[c[i]] + 1, -1)
    rightest[c[i]] = i
    bit.add(i + 1, 1)
    # print(bit.tree)

    while current_q < Q and lr[current_q][1] == i + 1:
        ans[lr[current_q][2]] = bit.sum(lr[current_q][1]) - bit.sum(lr[current_q][0] - 1)
        current_q += 1

for i in range(Q):
    print(ans[i])


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

int main() {
  int answer = 0 ;
  
  for ( int i = 0 ; i < 4 ; i++ ) {
    char x ;
    cin >> x ;
    if(x=='+') answer++ ;
    if(x=='-') answer-- ;
  }
  
  cout << answer << endl ;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

fn max(a: f64, b: f64) -> f64 {
    if a >= b {
        return a;
    }
    return b;
}

fn main() {
    input! {
      n: usize,
      k: usize,
      mat: [f64; n],
    }
    let mut p_map = std::collections::HashMap::new();

    // create map
    let mut mu_max = 0.;
    for i in 0..n {
        let key = mat[i].to_string();
        if p_map.contains_key(&key) {
            continue;
        }
        let mut temp_mu = 0.;
        let p: f64 = 1. / mat[i];
        for ii in 1..mat[i] as i32 + 1 {
            temp_mu += p * (ii as f64);
        }
        p_map.insert(key, temp_mu);
    }

    // calc max
    let mut mu = 0.;
    let mut mu_max = 0.;
    for i in 0..n {
        let key = mat[i].to_string();
        mu = mu + p_map.get(&key).unwrap();
        if i + 1 >= k {
            mu_max = max(mu_max, mu);

            let key = mat[i + 1 - k].to_string();
            mu = mu - p_map.get(&key).unwrap();
        }
    }
    println!("{}", mu_max);
}


Measured memory_bytes: 6396
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main(){
	int N; 
	cin >> N; 
	long long int X[100010] = {}; 
	long long int D[100010] = {}; 
	for(int i = 0; i < N; i++){
		cin >> X[i]; 
	}
	for(int i = 1; i < N; i++){
		D[i] = X[i] - X[i-1]; 
	}
	int M; 
	long long int K; 
	cin >> M >> K; 
	int A[100010] = {}; // 1セットでどこに移るか
	for(int i = 1; i < N; i++){
		A[i] = i; 
	}
	for(int i = 0; i < M; i++){
		int a; 
		cin >> a; 
		swap(A[a-1], A[a]); 
	}
	int E[100010] = {}; // K回後の距離の添字
	for(int i = 1; i < N; i++){
		if(E[i]) continue; 
		vector<int> Y; 
		Y.push_back(i); 
		int k = i; 
		for(int j = 0; j < 114514; j++){
			k = A[k];
			if(k != Y.at(0)){
				Y.push_back(k); 
			}
			else{
				int P = (int)(K % Y.size()); 
				for(int l = 0; l < Y.size(); l++){
					E[Y.at(l)] = Y.at((P+l) % Y.size()); 
				}
				break; 
			}
		}
	}
	long long int z = X[0]; 
	cout << X[0] << endl; 
	for(int i = 1; i < N; i++){
		cout << z + D[E[i]] << endl; 
		z += D[E[i]]; 
	}
}

Measured memory_bytes: 3696
#include<bits/stdc++.h>
#define int long long 
#define LL long long 
#define LD long double
#define PI 3.14159265358979323846
#define MOD ((LL)1e9+7)
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

int32_t main()
{
	IOS
	int n,q;cin>>n>>q;
	string s;cin>>s;
	vector<int>A(n+1);
	for(int i=1;i<=n;i++)
	{
		int id=i-1;
		if(id+1<n && s[id]=='A' && s[id+1]=='C')A[i]++;
	}
	for(int i=1;i<=n;i++)A[i]+=A[i-1];
	
	while(q--)
	{
		int l,r;cin>>l>>r;
		int ans=A[r]-A[l-1];
		int id=r-1;
		if(id+1<n && s[id]=='A' && s[id+1]=='C')ans--;
		cout<<max(ans,0LL)<<endl;
	}
	
	
	

	
}


Measured memory_bytes: 1872
#include <bits/stdc++.h>
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define rep(i,l,r) for(int i = (int)l;i<(int)r;i++)
#define td(v) v.begin(),v.end()
#define sz(v) (int)v.size()
//#define M   1000000007 // 1e9 + 7
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
inline ll mod(ll n, ll m){ ll ret = n%m; if(ret < 0) ret += m; return ret; }
ll gcd(ll a, ll b){return (b == 0LL ? a : gcd(b, a%b));}
ll exp(ll a,ll b,ll m){
    
    if(b==0LL) return 1LL;
    if(b==1LL) return mod(a,m);
    ll k = mod(exp(a,b/2,m),m);
    if(b&1LL){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}

const int N = 200100;

int32_t main(){
  fastio;
  string s;
  cin>>s;
  int n = s.size();
  int res=0;
  map<int,int> mp;

  int pot = 1;
  int pre=0;
  mp[0] = 1;
  for(int i=n-1;i>=0;i--){
    pre+= (s[i]-'0')*pot;
    pre%=2019;
    res+=mp[pre];
    //cout << pre << endl;
    mp[pre]++;


    pot*=10;
    pot%=2019;
  }
  cout<< res << endl;

  // Math -> gcd it all
  // Did u check N=1? Did you switch N,M?
}

Measured memory_bytes: 3752
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll=long long;
int main()
{
    ll n,all=0,sum=0;
    cin>>n;
    vector<ll> a(n);
    rep(i,n){
        cin>>a[i];
        all+=a[i];
    }
    ll ans=all;
    rep(i,n){
        sum+=a[i];
        all-=a[i];
        ans=min(abs(all-sum),ans);
    }
    cout<<ans;
}

Measured memory_bytes: 4784
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <map>
#include <vector>

using namespace std;

int main(void) {
  int N;
  cin >> N;
  int x[N], y[N];
  for (int i = 0; i < N; i++) {
    cin >> x[i] >> y[i];
  }
  double s = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      s += sqrt(pow(x[i] - x[j], 2) + pow(y[i] - y[j], 2));
    }
  }
  int a = 1;
  for (int i = 1; i <= N; i++) {
    a *= i;
  }
  printf("%.16f", s / N);
  //cout << s / N << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
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(){
    int n;cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    map<int,int> mp;
    rep(i,n){
        mp[a[i]]++;
    }
    int cnt=0;
    for(auto p:mp){
        if(p.second>1) cnt+=p.second-1;
    }
    if(cnt%2==0) cout << n-cnt << endl;
    else cout << n-cnt-1 << endl;
    return 0;
}

Measured memory_bytes: 5376
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <climits>
using namespace std;
typedef long long ll;
int main(void){
    int a,b,c,tmp;
    cin >> a >> b >> c;
    tmp = a-b;
    cout << max(0,c-tmp) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set

using namespace std;

const ll MOD = 1000000007;

int main() {
  ll n;
  scanf("%lld", &n);

  bool denied = false;
  vector<ll> a(n);
  for (ll i = 0; i < n; i++) {
    ll v;
    scanf("%lld", &v);

    if (v % 2 == 0) {
      if (v % 3 != 0 && v % 5 != 0) {
        denied = true;
      }
    }
  }

  if (denied) {
    cout << "DENIED" << endl;
  } else {
    cout << "APPROVED" << endl;
  }
}


Measured memory_bytes: 256
use proconio::*;

#[fastout]
fn run() {
    input! {
        n: usize,
        m: usize,
    }
    let mut ans = vec![];
    for d in 1.. {
        let a = d;
        let b = n + 1 - d;
        if b - a != 2 * d - 1 {
            ans.push((a, b));
        }
        if ans.len() >= m {
            break;
        }
        let mid = (n + 1) / 2;
        let a = mid - d;
        let b = mid + d;
        if b - a != (n - b) + a {
            ans.push((a, b));
        }
        if ans.len() >= m {
            break;
        }
    }
    let mut ok = vec![true; n];
    for &(a, b) in ans.iter() {
        let d = std::cmp::max(a, b) - std::cmp::min(a, b);
        assert!(ok[d]);
        assert!(ok[(n - d) % n]);
        ok[d] = false;
        ok[n - d] = false;
    }
    for (a, b) in ans {
        println!("{} {}", a, b);
    }
}

fn main() {
    run();
}


Measured memory_bytes: 3716
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 2e+9 + 10;
typedef pair<ll, ll> P;

int main() {
    ll C;
    cin>>A>>B>>C;
    cout<<((A + B == C) || (B + C == A) || (C + A == B) ? "Yes" : "No")<<endl;
}

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

using namespace std;

const long NMAX = 100010;
const long dx[10] = {0, 0, 0, 0, 1, 1, 1, 2, 2, 2};
const long dy[10] = {0, 0, 1, 2, 0, 1, 2, 0, 1, 2};

struct Point{
    long x;
    long y;
};

struct CMP{
    bool operator()(const Point& p, const Point& q){
        if (p.x == q.x) return p.y < q.y;
        return p.x < q.x;
    }
};


long long H, W, N;
Point a[NMAX];
map<Point, int, CMP> F;
long long kq[15];

bool kiemtra(long zx, long zy){
    return zx>0 && zy>0 && zx<=H && zy<=W;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL); cout.tie(NULL);
    cin >> H >> W >> N;
    for (long i=1; i<=N; ++i){
        cin >> a[i].x >> a[i].y;
        for (int j=1; j<=9; ++j){
            long xx = a[i].x + dx[j];
            long yy = a[i].y + dy[j];
            if (kiemtra(xx, yy) && kiemtra(xx-2, yy-2)){
                Point tmp = {xx, yy};
                if (F.find(tmp) != F.end()) F[tmp]++;
                else F[tmp] = 1;
            }
        }
    }
    for (auto it : F) kq[it.second]++;
    long long tmp_kq = (W-2) * (H-2);
    for (int i=1; i<=9; ++i) tmp_kq -= kq[i];
    kq[0] = tmp_kq;
    for (int i=0; i<=9; ++i) cout << kq[i] << endl;
    return 0;
}


Measured memory_bytes: 58112
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
ll d1[101010], d2[101010];
ll lb1[101010], ub1[101010], lb2[101010], ub2[101010];
int main()
{
	int num;
	scanf("%d", &num);
	for (int i = 0; i < num; i++)scanf("%lld", &d1[i]);
	for (int i = 0; i < num; i++)scanf("%lld", &d2[i]);
	int now = -1;
	for (int i = 0; i < num; i++)
	{
		if (now < d1[i])lb1[i] = ub1[i] = d1[i];
		else lb1[i] = 1, ub1[i] = d1[i];
		now = d1[i];
	}
	now = -1;
	for (int i = num - 1; i >= 0; i--)
	{
		if (now < d2[i])lb2[i] = ub2[i] = d2[i];
		else lb2[i] = 1, ub2[i] = d2[i];
		now = d2[i];
	}
	ll ans = 1;
	for (int i = 0; i < num; i++)
	{
		ll t = min(ub1[i], ub2[i]) - max(lb1[i], lb2[i]) + 1;
		if (t < 0)ans = 0;
		ans = ans*t%mod;
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 4864
#include <stdio.h>
int main()
{
	char s[3];
	scanf("%s",s);
	int i,sum=0;
	for(i=0;i<3;i++)
	{
		if(s[i]=='A') sum++;
	}
	if(sum==3||sum==0) printf("No");
	else printf("Yes");
	return 0;
} 

Measured memory_bytes: 128
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int k = sc.nextInt();

		int [] p = new int[n];
		
		long sum = 0;
		
		for(int i = 0; i < n ; i++) {
			p[i] = sc.nextInt();
		}
		
		Arrays.sort(p);
		
		for(int i = 0; i < k ;i++) {
			sum += p[i];
		}
		
		System.out.println(sum);
		//String s = sc.next();
		//long n = sc.nextLong();
		//double n = sc.nextDouble();
		
		//for(int i = 0; i < ; i++)

		//System.out.println("Yes");
		//System.out.println("No");
		

	}
}


Measured memory_bytes: 38820
N = int(input())
hN = list(map(int, input().split()))

count = 0

mini = min(hN)
count += mini

hN = [hi - mini for hi in hN]

while sum(hN) > 0:
    cont = False
    for hi in hN:
        if hi > 0:
            if not cont:
                count += 1
                cont = True
        else:
            cont = False
    hN = [hi - 1 if hi > 0 else hi for hi in hN]
print(count)


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

#define loop(v, f, l) for(int v = (f), v##_ = (l); v < v##_; ++v)

using namespace std;

typedef long long int lint;
static inline int in(){ int x; scanf("%d", &x); return (x); }
static inline lint inl(){ lint x; scanf("%lld", &x); return (x); }

int main()
{
	for(int i = 0; i < 9; i++)
	{
		char line[32];
		char class_name[16];
		int num[2];
		fgets(line, 32, stdin);
		sscanf(line, "%s%d%d", class_name, &num[0], &num[1]);
		printf("%s %d %d\n", class_name, num[0] + num[1], num[0] * 200 + num[1] * 300);
	}
	return (0);
}

Measured memory_bytes: 1196
n, m = map(int, input().split())

A = [-1] * n

for i in range(m):
	s, c = map(int, input().split())
	if A[s-1] == c:
		continue
	if A[s-1] != -1:
	# if A[s-1] != -1 or (s == 1 and c == 0):
		print(-1)
		exit()
	A[s-1] = c
if n == 1:
	print(0 if A[0] == -1 else A[0])
else:
	if A[0] == 0:
		print(-1)
		exit()
	else:
		print(1 if A[0] == -1 else A[0], end='')
		for a in A[1:]:
			print(0 if a == -1 else a, end='')

Measured memory_bytes: 38256
// WARNING: Add compile option "-std=c++11" for C++11 compile.

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

// Macro
#define REP(i, N) for(int i=0; i<(int)N; i++)
#define REPR(i, N) for(int i=(int)N-1; i>=0; i--)

// Type
using ll = long long;
template <typename T = int> using P = pair<T, T>;

// Constants
const ll MOD = 1000000007;

/**
  型に合わせたINFを返す
  int: 214,748,364 (2.14 * 1e8)
  ll : 922,337,203,685,477,580 (9.22 * 1e17)
*/
template <typename T = int>
T getINF() {
  // NOTE: INF同士を足してもオーバーフロー起こさないように、10で割っている
  return numeric_limits<T>::max() / 10;
}

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

int main() {
  int a, b;
  cin >> a >> b;
  if(a>= 13) cout << b << endl;
  else if(a >= 6) cout << (b/2) << endl;
  else cout << "0" << endl;
  return 0;
}

Measured memory_bytes: 256
// A.cpp
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
#define ll long long
using namespace std;
const int INF = 0x3f3f3f3f, MX_N = 1e5 + 200;
ll n, arr[MX_N], dp[MX_N], K;
int main()
{
    scanf("%lld%lld", &n, &K);
    for (int i = 1; i <= n; i++)
        scanf("%lld", &arr[i]);
    memset(dp, INF, sizeof(dp));
    dp[1] = 0;
    for (int i = 2; i <= n; i++)
        for (int j = i - 1; j >= 1 && i - j <= K; j--)
            dp[i] = min(dp[i], dp[j] + abs(arr[i] - arr[j]));
    printf("%lld", dp[n]);
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
const int INF = 2e9;
int main() {
    int N; cin >> N;
    vector<int> A(N); for (auto &a : A) cin >> a;
    vector<vector<int>> G(N);
    for (int i = 0; i < N - 1; i++) {
        int u, v; cin >> u >> v; u--, v--;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    vector<int> ans(N), dp(N, INF);
    auto recur = [&](auto &recur, int node, int prev) -> void {
        int pos = lower_bound(begin(dp), end(dp), A[node]) - begin(dp);
        int save = dp[pos];
        dp[pos] = A[node];
        int cnt = lower_bound(begin(dp), end(dp), INF - 1) - begin(dp);
        ans[node] = cnt;
        for (int next : G[node]) if (next != prev) {
            recur(recur, next, node);
        }
        dp[pos] = save;
    };
    recur(recur, 0, -1);
    for (auto a : ans) cout << a << '\n';
    return 0;
}

Measured memory_bytes: 30880
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int MOD = 1000000007;
const int INF = numeric_limits<int>::max() / 2;

typedef pair<int, int> P;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
 
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int N, M;
    cin >> N;
    map<string, int> mp1;
    rep(i,N){
      string S;
      cin >> S;
      mp1[S]++;
    }
    cin >> M;
    rep(i,M){
      string T;
      cin >> T;
      mp1[T]--;
    }
    int ans = 0;
    for(auto P : mp1){
      ans = max(ans, P.second);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#define X first
#define Y second
using namespace std;

int main(){
	int n = 0;
	while(cin >> n){
		int sum = 1;
		if(cin.eof()) break;
		for(int i = 1; i <= n; i++){
			sum += i;
		}
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 1156
n = int(input())
a = list(map(int, input().split()))

if len(set(a)) == 1:
    if list(set(a))[0] != 1:
        print(-1)
        exit()
    elif len(a) == n:
        pass
    else:
        print(0)
        exit()


x = 1
count = 0
for i in a:
    if i == x:
        x += 1
    else:
        count += 1
if count == n:
    print(-1)
else:
    print(count)

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

using namespace std;

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

  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; ++i) {
    cin >> v[i];
  }
  map<int, int> odds, evens;
  int oddc = 0, evenc = 0;
  for (int i = 0; i < n; ++i) {
    if (i % 2) {
      odds[v[i]]++;
      oddc++;
    } else {
      evens[v[i]]++;
      evenc++;
    }
  }
  vector<pair<int, int>> oddv, evenv;
  for (auto &it : odds) {
    oddv.push_back(make_pair(it.second, it.first));
  }
  for (auto &it : evens) {
    evenv.push_back(make_pair(it.second, it.first));
  }
  sort(oddv.rbegin(), oddv.rend());
  sort(evenv.rbegin(), evenv.rend());
  if (oddv[0].second == evenv[0].second) {
    cout << min(oddc - oddv[0].first + evenc - evenv[1].first,
                oddc - oddv[1].first + evenc - evenv[0].first)
         << "\n";
  } else {
    cout << oddc - oddv[0].first + evenc - evenv[0].first << "\n";
  }
}


Measured memory_bytes: 6524
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < n; ++i)
 
main(void) {
  ll n,x,m;cin>>n>>x>>m;
  vector<int> id(m,-1);
  vector<int> a;
  int len=0;
  ll tot=0;
  while(id[x]==-1){
    a.push_back(x);
    id[x]=len;
    len++;
    tot+=x;
    x=x*x%m;
  }
  int c=len-id[x];
  ll s=0;
  for(int i=id[x];i<len;i++) s+=a[i];
  ll ans=0;
  if(n<=len){
    rep(i,n) ans+=a[i];
  } else {
    ans+=tot;
    n-=len;
    ans+=s*(n/c);
    n%=c;
    rep(i,n) ans+=a[id[x]+i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3968
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
gosa = 1.0 / 10**10
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    n,m,R = LI()
    t = LI()
    e = collections.defaultdict(list)
    for _ in range(m):
        a,b,c = LI()
        e[a].append((b,c))
        e[b].append((a,c))

    # メソッドのみ版
    def search(s):
        d = collections.defaultdict(lambda: inf)
        d[s] = 0
        q = []
        heapq.heappush(q, (0, s))
        v = collections.defaultdict(bool)
        while len(q):
            k, u = heapq.heappop(q)
            if v[u]:
                continue
            v[u] = True

            for uv, ud in e[u]:
                if v[uv]:
                    continue
                vd = k + ud
                if d[uv] > vd:
                    d[uv] = vd
                    heapq.heappush(q, (vd, uv))

        return d
    td = {}
    for i in t:
        td[i] = search(i)

    r = inf
    for ta in itertools.permutations(t):
        tr = 0
        for i in range(1,R):
            tr += td[ta[i-1]][ta[i]]
        if tr < r:
            r = tr

    return r

print(main())





Measured memory_bytes: 11696
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

N,C,K = inpl()
tt = [int(input()) for i in range(N)]
tt.sort()
tt.append(10**10)
ans = n = s = 0

for i in range(N):
	t = tt[i]
	if n == 0:
		s = t
	n += 1
	if n == C or tt[i+1]-s > K:
		ans += 1
		n = 0

print(ans)


Measured memory_bytes: 8672
#include<bits/stdc++.h>
using namespace std;
long long ans=0LL;
string S;
int main(){
    cin>>S;
    long long dp[2019],dp2[2019];
    memset(dp,0LL,sizeof dp);
    memset(dp2,0LL,sizeof dp2);
    dp[S[0]-'0']=1LL;
    for(int i=1;i<S.size();i++){
        int n=S[i]-'0';
        for(int j=0;j<2019;j++){
            if(dp[j]!=0LL){
                dp2[(j*10+n)%2019]+=dp[j];
            }
        }
        for(int j=0;j<2019;j++){dp[j]=dp2[j],dp2[j]=0LL;}
        dp[n]++;
        ans+=dp[0];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3776
import itertools
import math
import fractions
import functools
a, b, c, d = map(int, input().split())


# if c // b > a // d:
#     print("Yes")
# else:
#     print("No")

while c > 0 and a > 0:
    c = c - b
    if c <= 0:
        print('Yes')
        quit()
    a = a - d
    if a<= 0:
        print("No")
        quit()
    

Measured memory_bytes: 72804
import java.util.Scanner;
import java.util.Arrays;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int[] X = new int[M];
    for(int i = 0;i < M;i++) X[i] = sc.nextInt();
    Arrays.sort(X);
    int[] A = new int[M-1];
    for(int i = 0;i < M-1;i++) A[i] = X[i+1] - X[i];
    Arrays.sort(A);
    int ans = 0;
    for(int i = 0;i < M - N;i++) ans = ans + A[i];
    System.out.println(ans);
  }
}

Measured memory_bytes: 49760
import sys

input = lambda: sys.stdin.readline().rstrip()
mod = 10**9 + 7


def solve():
    N, M = map(int, input().split())
    A = [0 for _ in range(N + 1)]
    for i in range(M):
        a = int(input())
        A[a] = 1

    dp = [0 for _ in range(N + 1)]
    dp[0] = 1

    for i in range(0, N):
        if i + 1 <= N and A[i + 1] != 1:
            dp[i + 1] += dp[i]
            dp[i + 1] %= mod
        if i + 2 <= N and A[i + 2] != 1:
            dp[i + 2] += dp[i]
            dp[i + 2] %= mod

    print(dp[N])


if __name__ == '__main__':
    solve()


Measured memory_bytes: 7832
#!/usr/bin/python3
# li = list(map(int,input().split()))	

n = int(input())
h = list(map(int,input().split()))	

now=0
for i in h :
    if now==-1 :
        break
    if now < i :
        now=i-1
    elif now > i :
        now = -1

if now != -1 :
    print("Yes")
else :
    print("No")

Measured memory_bytes: 14396
// https://atcoder.jp/contests/arc098/tasks/arc098_b
#include <cstdio>
#include <algorithm>

using namespace std;

using ll = long long;

int A[200000];
int bits[20];

int main()
{
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &(A[i]));
  }
  for (int i = 0; i < 20; i++) {
    bits[i] = -1;
  }
  int sum = A[0];
  ll c = 1;
  for (int i = 0; i < 20; i++) {
    if ((A[0] >> i)&1) bits[i] = 0;
  }
  int streak = 1;
  ll streak_start = 0;
  for (ll i = 1; i < n; i++) {
    for (int j = 0; j < 20; j++) {
      if ((A[i]>>j)&1) {
        if (streak_start <= bits[j]) {
          streak_start = max(streak_start, (ll)(bits[j]+1));
        }
        bits[j] = i;
      }
    }
    c += i-streak_start+1;
  }
  printf("%lld\n", c);
  return 0;
}


Measured memory_bytes: 896
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main() {
  int n,m,s,e;
  cin >> n >> m;
  vector<pair<int,int>> p(m);
  for(int i=0; i<m; i++) {
    cin >> s >> e;
    p[i]=make_pair(e,s);
  }
  sort(p.begin(),p.end());
  int ans=0,end=0;
  for(int i=0; i<m; i++) {
    if(end<=p[i].second) {
      ans++;
      end=p[i].first;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1152
use std::collections::HashMap;
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s = read::<String>().chars().collect::<Vec<char>>();
    let k = read::<usize>();
    let mut ans = '1';
    for i in 0..std::cmp::min(k, s.len()) {
        let c = s[i];
        if c != '1' {
            ans = c;
            break;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
	int dx = x2 - x1, dy = y2 - y1;
	int x3 = x2 - dy, y3 = y2 + dx;
	int x4 = x3 - dx, y4 = y3 - dy;
	cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

class UnionFind {
public:
    vl parent;  // 親ノード
    vl Siz;  // 集合の大きさ
    
    // コンストラクタ
    UnionFind(ll n): parent(n), Siz(n, 1) {
        rep(i, n) {
            parent[i] = i;
        }
    }

    // n要素で初期化
    void init(ll n) {
        parent.resize(n);
        Siz.assign(n, 1);
        rep(i, n) {
            parent[i] = i;
        }
    }

    // xの属する集合の根を求める
    ll root(ll x) {
        if(parent[x] == x) {
            return x;
        }
        else {
            return parent[x] = root(parent[x]);
        }
    }

    // xとyの属する集合を併合
    void unite(ll x, ll y) {
        x = root(x);
        y = root(y);
        if(x == y) {
            return;
        }
        if(Siz[x] < Siz[y]) {
            swap(x, y);
        }
        Siz[x] += Siz[y];
        parent[y] = x;
    }
    
    // xとyが同じ集合に属するかどうか
    bool same(ll x, ll y) {
        return root(x) == root(y);
    }

    // xの属する集合の要素数を求める
    ll size(ll x) {
        return Siz[root(x)];
    }
};
 
int main() {
    ll n, m, k;
    cin >> n >> m >> k;

    UnionFind Uni(n);
    Uni.init(n);
    vl cnt(n, 1);  // cnt[v] : v自身とvとつながっている頂点の個数
    rep(i, m) {
        ll a, b;
        cin >> a >> b;
        a--;  b--;
        cnt[a]++;
        cnt[b]++;
        Uni.unite(a, b);
    }

    vvl B(n);  // B[v] : 頂点vとブロック関係にある頂点の集まり
    rep(i, k) {
        ll c, d;
        cin >> c >> d;
        c--;  d--;
        B[c].pb(d);
        B[d].pb(c);
    }

    rep(i, n) {
        ll ans = Uni.size(i) - cnt[i];
        for(auto v : B[i]) {
            if(Uni.root(i) == Uni.root(v)) {
                ans--;
            }
        }
        cout << ans << " ";
    }
    
    cout << endl;
    re0;
}

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

int main() {
    int sum = 0;
    string s;
    while (cin >> s) {
        int t = 0;
        for (int i=0; i<(int)s.size(); ++i) {
            if (isdigit(s[i])) {
                t *= 10;
                t += s[i] - '0';
            } else {
                sum += t;
                t = 0;
            }
        }
        sum += t;
    }
    cout << sum << endl;
    return 0;
}

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

main(){
    int y , m , d;
    scanf("%d/%d/%d" , &y , &m , &d);

    if(y < 2019){
        printf("Heisei\n");
        return 0;
    }

    if(y == 2019){
        if(m < 4){
            printf("Heisei\n");
            return 0;
        }
        if(m == 4){
            if(d <= 30){
                printf("Heisei\n");
                return 0;
            }
        }
    }
    printf("TBD\n");

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long minarea(long h,long w){//縦h,横wの時の面積最小
  if(w%3==0) return 0;
  else{
    long d = 1e9;//なんか大きい数字
    for(int i=1;i<w;i++){//切り方を決め撃つ
      long a = h*i;
      long b = (w-i)*(h-h/2);
      long c = (w-i)*(h/2);
      d = min(d,max({a,b,c})-min({a,b,c}));
    }
    return min(d,h);//3の倍数以外の時のminはhなので
  }
}
int main(){
  long h,w;
  cin >> h >> w;
  cout << min(minarea(h,w),minarea(w,h)) << endl;//hとwが逆の時も考慮
}

Measured memory_bytes: 256
#include<cstdio>
int a[1000];
int d[1000];
int main()
{
	int n,m,k,i,j,s,b,p=0;
	scanf("%d%d%d",&n,&m,&k);
	for(j=1;j<=m;j++)
	scanf("%d",&a[j]);
	for(i=1;i<=n;i++)
	{   s=0;
		for(j=1;j<=m;j++)
		{
			 scanf("%d",&b);
			 s+=b*a[j];
		}
		if(s+k>0)
		{d[p++]=i;}
	}
	if(p==0)
	printf("%d\n",p);
	else
	{
		printf("%d\n",p);
	}
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


namespace ACprac
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] num1 = Console.ReadLine().Split(' ');
            int A = int.Parse(num1[0]);
            int B = int.Parse(num1[1]);
            int C = int.Parse(num1[2]);

            Console.WriteLine((B/A) < C ? (B/A) : C);
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <cstdlib>
using namespace std;
#define INF 1e9
#define MAX_E 500000
#define MAX_V 100000
 
struct edge {int u, v, cost;};
edge es[MAX_E];
 
int dis[MAX_V];
int V, E, r;
 
void bellman_ford(int s){
  for(int i = 0; i < V; i++) dis[i] = INF;
  dis[s] = 0;
  int count = 0;
  while(true){
    if(++count == V && count > 1){
      cout << "NEGATIVE CYCLE" << endl;
      exit(0);
    }
    bool update = false;
    for(int i = 0; i < E; i++){
      edge e = es[i];
      if(dis[e.u] != INF && dis[e.v] > dis[e.u] + e.cost){
        dis[e.v] = dis[e.u] + e.cost;
        update = true;
      }
    }
    if(!update) break;
  }
}
 
int main(void){
  int s, t, d;
  cin >> V >> E >> r;
  for(int i = 0; i < E; i++){
    cin >> s >> t >> d;
    edge e;
    e.u = s; e.v = t; e.cost = d;
    es[i] = e;
  }
  bellman_ford(r);
  for(int i = 0; i < V; i++){
    if(dis[i] == INF) cout << "INF" << endl;
    else cout << dis[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 1192
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <deque>
#include <stack>

using namespace std;

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

	int n, x;
	int m[110];
	cin >> n >> x;
	for (int i = 0; i < n; i++) {
		cin >> m[i];
		x -= m[i];
	}

	sort(m, m + n);
	int ans = n + x / m[0];
	cout << ans << endl;
}

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

using namespace std;

double X[100005];
double Y[100005];
char mode[1000005];

int main(){
	int N;
	scanf("%d", &N);
	
	double y_u_max = -1e9;
	double y_u_min = 1e9;
	double y_d_max = -1e9;
	double y_d_min = 1e9;
	double x_l_max = -1e9;
	double x_l_min = 1e9;
	double x_r_max = -1e9;
	double x_r_min = 1e9;
	
	double y_fixed_max = -1e9;
	double y_fixed_min = 1e9;
	double x_fixed_max = -1e9;
	double x_fixed_min = 1e9;
	
	for(int i = 0; i < N; i ++){
		int x, y;
		char z;
		scanf(" %d %d %c", &x, &y, &z);
		X[i] = x;
		Y[i] = y;
		mode[i] = z;
		if(z == 'U' || z == 'D'){
			x_fixed_max = max(X[i], x_fixed_max);
			x_fixed_min = min(X[i], x_fixed_min);
		}else{
			y_fixed_max = max(Y[i], y_fixed_max);
			y_fixed_min = min(Y[i], y_fixed_min);
		}
		
		if(z == 'U'){
			y_u_max = max(Y[i], y_u_max);
			y_u_min = min(Y[i], y_u_min);
		}else if(z == 'D'){
			y_d_max = max(Y[i], y_d_max);
			y_d_min = min(Y[i], y_d_min);
		}else if(z == 'L'){
			x_l_max = max(X[i], x_l_max);
			x_l_min = min(X[i], x_l_min);
		}else{
			x_r_max = max(X[i], x_r_max);
			x_r_min = min(X[i], x_r_min);
		}
	}
	
	//printf("%.1f %.1f %.1f %.1f\n", x_fixed_min, x_fixed_max, y_fixed_min, y_fixed_max);
	
	double ans = 1e18;
	for(int time1 = 0; time1 <= 4e8+1; time1 ++){
		/*double x_max = -1e9;
		double x_min = 1e9;
		double y_max = -1e9;
		double y_min = 1e9;
		
		for(int i = 0; i < N; i ++){
			x_max = max(x_max, X[i]);
			x_min = min(x_min, X[i]);
			y_max = max(y_max, Y[i]);
			y_min = min(y_min, Y[i]);
		}
		double t = time1 / 2.0;
		
		double temp = (x_max-x_min) * (y_max-y_min);*/
		//printf("t=%.1f %.1f %.1f %.2f\n", t, x_max-x_min, y_max-y_min, temp);
		
		double t = time1 / 2.0;
		
		double x_max2 = max(max(x_r_max+t, x_l_max-t), x_fixed_max);
		double x_min2 =min(min(x_r_min+t, x_l_min-t), x_fixed_min);
		
		double y_max2 = max(max(y_u_max+t, y_d_max-t), y_fixed_max); 
		double y_min2 = min(min(y_u_min+t, y_d_min-t), y_fixed_min);
		
		double temp2 = (x_max2-x_min2) * (y_max2-y_min2);
		ans = min(ans, temp2);
		//printf("%.1f\n", y_d_min-t);
		//printf("t=%.1f %.1f %.1f %.1f %.1f %.2f\n", t, y_max, y_max2, y_min, y_min2, temp2);
		
		/*for(int i = 0; i < N; i ++){
			if(mode[i] == 'U'){
				Y[i] += 0.5;
			}else if(mode[i] == 'D'){
				Y[i] -= 0.5;
			}else if(mode[i] == 'L'){
				X[i] -= 0.5;
			}else if(mode[i] == 'R'){
				X[i] += 0.5;
			}
		}*/
	}
	
	printf("%.10f", ans);
	
	return 0;
}


Measured memory_bytes: 1920
#include<iostream>
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	int c = b - a;
	int B = 0;
	int A = 0;
	for (int i = 0; i < c; ++i) {
		B += i;
	}
	for (int i = 0; i <= c; ++i) {
		A += i;
	}
	cout << B - a << endl;
	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict

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

MOD = 998244353

p = defaultdict(int)
for d in D:
    p[d] += 1

if p[0] == 1 and D[0] == 0:
    ans = 1
    for i in range(N + 1):
        ans *= p[i] ** p[i + 1]
        ans %= MOD

    print(ans % MOD)

else:
    print(0)


Measured memory_bytes: 98264
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

int A[3][3];
bool B[3][3];
map<int, pair<int,int>> mp;

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

    for(int i=0; i<3; i++) for(int j=0; j<3; j++) {
        cin >> A[i][j];
        mp[A[i][j]] = make_pair(i, j);
    }
    
    int tt;
    cin >> tt;
    for(int i=0; i<tt; i++) {
        int x;
        cin >> x;
        if(mp.count(x)) {
            int a=mp[x].first, b=mp[x].second;
            B[a][b]=true;
        }
    }

    for(int i=0; i<3; i++) {
        if(B[i][0] && B[i][1] && B[i][2]) {
            cout << "Yes" << endl;
            return 0;
        }
        if(B[0][i] && B[1][i] && B[2][i]) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    if(B[0][0] && B[1][1] && B[2][2]) {
        cout << "Yes" << endl;
        return 0;
    }


    if(B[0][2] && B[1][1] && B[2][0]) {
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<int>>;
using P=pair<int,int>;


int i,j,n,m,ans=0;
vector<bool> visit;
void dfs(int,int);
Graph G;

int main(){
    cin>>n>>m;
    G.resize(n);
    visit.assign(n,0);

    for(i=0;i<m;i++){
        int a,b;
        cin>>a>>b;a--;b--;
        G[a].push_back({b});
        G[b].push_back({a});
    }
    
    visit[0]=1;
    dfs(n,0);
    
    cout<<ans<<endl;
    return 0;
}
void dfs(int k,int state){//state:今いる場所
    
    for(auto next:G[state]){
        if(visit[next]!=1){//訪れていないとき
            visit[next]=1;//訪れた
            dfs(k-1,next);//次へ
            visit[next]=0;
            /*一通り訪れ終えたらstate以降を元に戻し、
            別の道で一筆書き可能か調べる*/
        }
    }

    if(k==1){//適パターン(一筆書き可能ならば、n-1辺のみを通るので、k==1ならば可能)　
        ans++;
        return;    
    }

    return;
}

Measured memory_bytes: 256
/**
*    author:  yuya1234
*    created: 13.07.2020 15:42:04
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define FORV(i,v) for(auto i=v.begin(); i!=v.end();i++)

#define SORT(s) sort((s).begin(),(s).end())
#define SORTD(s) sort((s).rbegin(),(s).rend())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define SZ(x) ((int)(x).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))

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 gcd(int a,int b){return b?gcd(b,a%b):a;}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  //std::cout << std::fixed << std::setprecision(15);

  int n,a,b,c,d;
  cin>>n>>a>>b>>c>>d;

  a--;
  b--;
  c--;
  d--;
  string s;
  cin>>s;

  string ans="Yes";

  if(c<d){
    for(;;){
      if(s[b+2]=='.'){
        b+=2;
      }
      else if(s[b+1]=='.'){
        b+=1;
      }
      else{
        ans="No";
        break;
      }
      if(b==d){
        s[b]='#';
        break;
      }
    }
    for(;;){
      if(s[a+2]=='.'){
        a+=2;
      }
      else if(s[a+1]=='.'){
        a+=1;
      }
      else{
        ans="No";
        break;
      }
      if(a==c){
        s[a]='#';
        break;
      }
    }
  }
  else{
    for(;;){
      if(s[a+2]=='.' && a+2!=b){
        a+=2;
      }
      else if(s[a+1]=='.' && a+1!=b){
        a+=1;
      }
      else if(s[b+1]=='.' && b+1<SZ(s)){
        b+=1;
      }
      else if(s[b+2]=='.' && b+2<SZ(s)){
        b+=2;
      }
      else{
        ans="No";
        break;
      }
      if(a==c){
        s[a]='#';
        break;
      }
    }
    for(;;){
      if(b==d){
        s[b]='#';
        break;
      }
      if(s[b+2]=='.'){
        b+=2;
      }
      else if(s[b+1]=='.'){
        b+=1;
      }
      else{
        ans="No";
        break;
      }
    }
  }

  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 3728
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
        string[] input = ReadLine().Split(' ');
        int n = int.Parse(input[0]);
        int m = int.Parse(input[1]);
//        int a = int.Parse(input[2]);
//        int b = int.Parse(input[3]);*/
//        string temp = ReadLine();
//        int a = int.Parse(ReadLine());
//        int b = int.Parse(ReadLine());
//        int c = int.Parse(ReadLine());
//        int d = int.Parse(ReadLine());
//        string a = ReadLine();
//        string b = ReadLine();
//        string c = ReadLine();
        if(n+m==15){
            WriteLine("+");
        }else if(n*m == 15){
            WriteLine("*");
        }else{
            WriteLine("x");
        }
    }
}

Measured memory_bytes: 11092