akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")
#pragma GCC target("sse4.1")

#ifdef LOCAL
//#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define ford(i, n) for (int i = ((int)(n) - 1); i >= 0; --i)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef pair<int, int> pii;
typedef vector<pii> vii;
#define sz(c) (int)(c).size()
#define all(c) (c).begin(), (c).end()

#ifdef LOCAL
#define eprintf(args...) fprintf(stderr, args), fflush(stderr);
#else
#define eprintf(args...) ;
#endif

int l;

bool read ()
{
    if (!(cin >> l))
        return false;

    return true;
}

struct edge
{
    int from, to, cost;
};

pair<int, vector<edge>> solve (int l)
{
    if (l == 1)
        return mp(1, vector<edge>());

    auto res = solve (l / 2);

    {
        for (auto &e : res.second)
            e.from++, e.to++;
        res.first++;
        res.second.pb (edge{1, 2, l / 2});
        res.second.pb (edge{1, 2, 0});
    }

    if (l % 2 == 1)
        res.second.pb (edge{1, res.first, l - 1});
    return res;
}

int32_t main()
{
#ifdef LOCAL
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    while (read())
    {
        auto ans = solve(l);
        cout << ans.first << ' ' << sz(ans.second) << endl;
        for (const auto &e : ans.second)
            cout << e.from << ' ' << e.to << ' ' << e.cost << '\n';
    }

    return 0;
}


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

int main() {
	int A;
	long long int B, N;
	cin >> A >> B >> N;

	if (N > B - 1) N = B - 1;
	cout << floor(A * N / B) - A * (N / B) << endl;
	return 0;
}

Measured memory_bytes: 3756
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		char[] updown = new char[w + 2];
		Arrays.fill(updown, '#');
		StringBuilder sb = new StringBuilder();
		sb.append(updown).append("\n");
		for (int i = 0; i < h; i++) {
			sb.append("#").append(sc.next()).append("#").append("\n");
		}
		sb.append(updown).append("\n");
		System.out.print(sb);
	}
}


Measured memory_bytes: 21332
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <set>
#include <utility>
#include <vector>

#define MAX_N (200000)
#define MAX_Q (200000)
#define INF (1000000000)

using namespace std;

int main(int argc, char *argv[]) {
  // read inputs
  int N, Q, bs[MAX_N], es[MAX_N], xs[MAX_N], ds[MAX_Q];
  scanf("%d %d", &N, &Q);
  for (int i = 0; i < N; i++) {
    scanf("%d %d %d", &bs[i], &es[i], &xs[i]);
  }
  for (int q = 0; q < Q; q++) {
    scanf("%d", &ds[q]);
  }

  // put works into vector
  vector<pair<int, pair<int, int>>> road_works;
  for (int i = 0; i < N; i++) {
    road_works.push_back(make_pair(xs[i], make_pair(bs[i], es[i])));
  }
  sort(road_works.begin(), road_works.end());

  // put people into vector
  set<pair<int, int>> people;
  for (int q = 0; q < Q; q++) {
    people.insert(make_pair(ds[q], q));
  }

  // solve
  int anss[MAX_Q];
  for (int q = 0; q < Q; q++) {
    anss[q] = -1;
  }
  for (int i = 0; i < N; i++) {
    const int x = road_works[i].first, b = road_works[i].second.first,
              e = road_works[i].second.second;
    // people that start in the range [b - x, e - x) will stop at x
    const auto it_begin = people.lower_bound(make_pair(b - x, -INF)),
               it_end = people.lower_bound(make_pair(e - x, -INF));
    for (auto it = it_begin; it != it_end; it++) {
      const int d = it->first, q = it->second;
      anss[q] = x;
      // printf("person q = %d, d = %d, will stop at x = %d, b = %d, e = %d\n", q,
      //        d, x, b, e);
    }
    people.erase(it_begin, it_end);
  }
  for (int q = 0; q < Q; q++) {
    printf("%d\n", anss[q]);
  }

  return 0;
}


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

int n,a[100009],b[100009] ,l[100009], r[100009]; 
long  long ans= 0;
void solve(int ind)
{
	if(ind>=n)
	return ;
	if(ind == n-1)
	{
		ans = ans + a[ind] ;
		return ;
	}
	else
	{
		if(a[ind+1]<=a[ind])
	  {
		 ans = ans + a[ind] ;
		 solve(ind+2) ;
	  }
		else
		{
		  ans= ans + a[ind] ;
	      solve(ind+1) ;	
		}
	    }
	}


int main()
{
    cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>l[i]>>r[i];
		if(l[i]<=r[i])
		a[i] = r[i]-l[i] ;
		else
		{
			if(l[i]%r[i] == 0)
			a[i] = 0;
			else
			a[i] = (r[i] - l[i]%r[i]) ;
		}
	}
	long long c=0,temp;
    for(int i=n-1;i>=0;i--)
    {
         int rem= (r[i]- (c+l[i])%r[i] )%r[i] ;
         ans = ans + rem ;
         //cout<<rem<<"k"<<i<<endl;
         c +=rem ;
	}
	cout<<ans<<endl;
	return 0 ;
}

Measured memory_bytes: 1408
use std::io::{self, Stdin};
use std::str::{self, FromStr};
use std::error::Error;

fn exec() {
    let mut sc = Scanner::new();
    let x: usize = sc.ne();
    let mut ans = (x / 11) * 2;
    ans += match x % 11 {
        val if val == 0 => 0,
        val if val <= 6 => 1,
        _ => 2,
    };
    println!("{}", ans);
}

fn main() {
    const STACK: usize = 16 * 1024 * 1024;
    let _ = std::thread::Builder::new()
        .stack_size(STACK)
        .spawn(|| { exec(); })
        .unwrap()
        .join()
        .unwrap();
}

#[allow(dead_code)]
struct Scanner {
    stdin: Stdin,
    id: usize,
    buf: Vec<u8>,
}

#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner {
        Scanner {
            stdin: io::stdin(),
            id: 0,
            buf: Vec::new(),
        }
    }
    fn next_line(&mut self) -> Option<String> {
        let mut res = String::new();
        match self.stdin.read_line(&mut res) {
            Ok(0) => None,
            Ok(_) => Some(res),
            Err(why) => panic!("error in read_line: {}", why.description()),
        }
    }
    fn next<T: FromStr>(&mut self) -> Option<T> {
        while self.buf.len() == 0 {
            self.buf = match self.next_line() {
                Some(r) => {
                    self.id = 0;
                    r.trim().as_bytes().to_owned()
                }
                None => return None,
            };
        }
        let l = self.id;
        assert!(self.buf[l] != b' ');
        let n = self.buf.len();
        let mut r = l;
        while r < n && self.buf[r] != b' ' {
            r += 1;
        }
        let res = match str::from_utf8(&self.buf[l..r]).ok().unwrap().parse::<T>() {
            Ok(s) => Some(s),
            Err(_) => {
                panic!("parse error, {:?}",
                       String::from_utf8(self.buf[l..r].to_owned()))
            }
        };
        while r < n && self.buf[r] == b' ' {
            r += 1;
        }
        if r == n {
            self.buf.clear();
        } else {
            self.id = r;
        }
        res
    }
    fn ne<T: FromStr>(&mut self) -> T {
        self.next::<T>().unwrap()
    }
}


Measured memory_bytes: 8572
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define si(v) int(v.size())
#define len(v) int(v.length())
#define lob(v,n) lower_bound(all(v),n)
#define lobi(v,n) lower_bound(all(v),n) - v.begin()
#define upb(v,n) upper_bound(all(v),n)
#define upbi(v,n) upper_bound(all(v),n) - v.begin()
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vc = vector<char>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}




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

    
    int N;
    cin >> N;
    vl A(N);
    in(N,A);
    
    ll ans = 0;
    queue<ll> aa;
    sort(all(A));
    reverse(all(A));
    
    aa.push(A[1]);
    ans += A[0];
    
    reps(i,2,N){
        
        ll aaa = aa.front();
        aa.pop();
        
        ans += aaa;
        aa.push(A[i]);
        
        if(i != N-1){
            i++;
            ans += aaa;
            aa.push(A[i]);
        }
        
    }
    
    cout << ans << endl;
    

    return 0;
}


Measured memory_bytes: 5580
use std::io;
use std::str::FromStr;

fn input_tuple() -> (u64, u64) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<u64> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn input_tuple_str() -> (String, String) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<String> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0].to_string(), vec[1].to_string())
}

fn main() {
    let (n, m) = input_tuple();
    let mut results: Vec<Vec<bool>> = vec![Vec::new(); n as usize];
    for _ in 0..m {
        let (p, s) = input_tuple_str();
        let p: usize = p.parse().unwrap();
        if s == "AC" {
            results[p-1].push(true);
        } else {
            results[p-1].push(false);
        }
    }
    let mut ans = 0;
    let mut pen = 0;
    for result in &results {
        if result.contains(&true) {
            ans += 1;
            for ac in result {
                if *ac {
                    break;
                }
                pen += 1;
            }
        }
    }
    // println!("{:?}", results);
    println!("{} {}", ans, pen);
}


Measured memory_bytes: 8444
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
typedef long long LL;

LL dp[51][51][2501];
int a[55];

int main(){
	int n,m,sum = 0;
	LL all = 0;
	cin >> n >> m;
	for(int i = 1;i <= n;i++) cin >> a[i],sum += a[i];
	dp[0][0][0] = 1;
	for(int i = 1;i <= n;i++){
		for(int j = 0;j <= i;j++){
			for(int k = 0;k <= sum;k++){
				if(k >= a[i] && j >= 1) dp[i][j][k] += dp[i - 1][j - 1][k - a[i]];
				dp[i][j][k] += dp[i - 1][j][k];
			}
		}
	}
	for(int j = 1;j <= n;j++){
		for(int k = 0;k <= 2500;k++){
			if(k % j == 0 && k / j == m) all += dp[n][j][k];
		}
	}
	cout << all << endl;
}

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

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  long long N,D;
  cin>>N>>D;
  
  int ans=0;
  for(int i=0;i<N;i++){
    long long x,y;
    cin>>x>>y;
    if((x*x+y*y)<=(D*D)) ans++;
  }
  
  cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 3612
#include<stdio.h>
int main(void){
    int n;
    int x;
    int i;
    int j;
    int l;
    int k;
    int f;
    while(1){
        f = 0;
        scanf("%d%d",&n,&x);
        if(n==0&&x==0){
            break;
        }
        k = 1;
            for(i=k;i<=n;i++){
                for(j=i+1;j<=n;j++){
                    for(l=j+1;l<=n;l++){
                        if(i+j+l==x){
                            //printf("%d %d %d\n",i,j,l);
                            f++;
                        }
                    }
                   //printf("{%d %d %d}\n",i,j,l);
                }
               //printf("[%d %d %d]\n",i,j,l);
            }
        printf("%d\n",f);
    }
    return 0;
}

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

using namespace std;
const long mod = 1000000007;
typedef long long lint;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(N) for(int i = 0; i < (int)(N); i++)
#define all(x) (x).begin(),(x).end()
#define length(x) ((int)(x).size())
#define prln(s) cout<<s<<endl;

#define str(s) string s;cin>>s;
#define int1(x) int x;cin>>x;
#define int2(x,y) int x,y;cin>>x>>y;

int main() {
  int1(X);
  int uresii = 0;
  int y500 = floor(X/500);
  uresii += y500 * 1000;
  int nokori = X - y500*500; // < 500
  int y5 = floor(nokori/5);
  uresii += y5 * 5;
  prln(uresii);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <vector>
#include <queue>
#include <map>
typedef unsigned long long ull;
typedef long long ll;
#define MAX 10005
using namespace std;

int main() {
  ll a,b,c;
  cin >> a >> b >> c;
  if(c > a+b) {
    c=a+b+1;
  }
  cout << c+b<< endl;

  return 0;
}

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

int sumofdigits(int x){
  int sum=0;
  while(x>0){
    sum+=x%10;
    x/=10;
  }

  return sum;
}//各桁の和を計算する関数
 
int main() {
  
  int N,x,kid=0;

  cin >> N >> x;

  vector<int> a(N);

  for(int i=0;i<N;i++){
    cin >> a.at(i);
  }

  sort(a.begin(),a.end());
  
  for(int i=0;i<N;i++){ 
    if(x>=a.at(i)){ 
    kid++;
    x-=a.at(i);
    }
  }
  
  if((kid==N)&&(x>0)) kid--;
  //全員満足していて、かつあまりのお菓子がある場合、配り切れていないので、最大の満足数を維持するには、
  //一人の子供に余り全てを押しつけ、犠牲となってもらう。
 
  cout << kid << endl;
 
  return 0;
}

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

using namespace std;
#define sqr(x) ((x)*(x))
#define cube(x) ((x)*(x)*(x))
#define GCD(a, b) __gcd(a, b)
#define LCM(a, b) ((a)*(b)/GCD(a,b))
#define MP make_pair
#define n1 first
#define n2 second
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define SI set<int>
#define SL set<ll>
#define MS multiset
#define MSI multiset<int>
#define MSLL multiset<ll>
#define PB push_back
#define PF push_front
#define VI vector<int>
#define VPI vector<pair<int,int>>
#define VLL vector<ll>
#define SZ(x) ((int)x.size())

typedef long long ll;

typedef unsigned long long ull;
typedef long double ld;
typedef double db;
const int INF = 1e9;
const int MOD = 1000000007;
const int N = 202055;
const int M = 1211;

VI g[N];
bool used[N];
int d1[N], d2[N];

void dfs1(int x, int p){
    used[x] = true;
    d1[x] = d1[p]+1;
    for (int q : g[x]){
        if (!used[q]) dfs1(q, x);
    }
}
void dfs2(int x, int p){
    used[x] = true;
    d2[x] = d2[p]+1;
    for (int q : g[x]){
        if (!used[q]) dfs2(q, x);
    }
}

void solve(){
    int n,u,v;
    cin >> n >> u >> v;

    for (int i = 1; i < n; i++){
        int x,y;
        cin >> x >> y;
        g[x].PB(y);
        g[y].PB(x);
    }

    d1[u] = -1;
    d2[v] = -1;
    dfs1(u, u);
    fill(used+1, used+n+1, false);
    dfs2(v, v);

    int ans = 0;
    for (int i = 1; i <= n; i++){
        if (d1[i] < d2[i]){
            ans = max(ans, d2[i]-1);
        }
    }

    cout << ans;

}

int main() {
    ios_base::sync_with_stdio(false);
#ifdef dxz05
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else

#endif

    int T = 1;
    //cin >> T;

    while (T--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 11648
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a[4];
	for(int i=1;i<=3;i++)cin>>a[i];
	sort(a+1,a+3+1);
	cout<<fabs(a[3]-a[2]+a[2]-a[1])<<endl;
	return 0;	
 } 


Measured memory_bytes: 256
S = gets.to_s
n = S.size
ansF = (753 - (S[0] + S[1] + S[2]).to_i).abs
(3..n - 2).each do |x|
  ansS = (753 - (S[x - 2] + S[x - 1] + S[x]).to_i).abs
  ansF = ansS if ansF > ansS
end
puts ansF

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (int)(a); v < (int)(b); ++v)
#define FORE(v, a, b) for(int v = (int)(a); v <= (int)(b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define RS resize
#define CLR clear
#define PB push_back
#define ALL(x) (x).begin(), (x).end()
using namespace std;

void split(string str, char chr, vector< string > *res){
	stringstream ss(str);
	string itm;
	while(getline(ss, itm, chr)){
		(*res).PB(itm);
	}
}

class Score{
public:
	int i, u, a, p;
	Score() : i(0), u(0), a(0), p(0) {}
};

bool comp(Score a, Score b){
	if(a.a != b.a){
		return a.a > b.a;
	}
	if(a.p != b.p){
		return a.p < b.p;
	}
	return a.i < b.i;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n, i, u, p, a;
	vector< Score > s;
	queue< int > q;
	vector< int > univ;
	
	
	while(cin >> n, n){
		s.RS(n);
		univ.CLR();
		univ.RS(1000);
		
		REP(j, n){
			cin >> i >> u >> a >> p;
			s[j].i = i;
			s[j].u = u;
			s[j].a = a;
			s[j].p = p;
		}
		
		sort(ALL(s), comp);
		
		REP(j, n){
			if(q.size() < 10 && univ[s[j].u - 1] < 3){
				q.push(s[j].i);
				++univ[s[j].u - 1];
			}else if(q.size() < 20 && univ[s[j].u - 1] < 2){
				q.push(s[j].i);
				++univ[s[j].u - 1];
			}else if(q.size() < 26 && univ[s[j].u - 1] == 0){
				q.push(s[j].i);
				++univ[s[j].u - 1];
			}
		}
		
		while(!q.empty()){
			cout << q.front() << endl;
			q.pop();
		}
	}
	
	return 0;
}

Measured memory_bytes: 1216
#include <iostream>

using namespace std;

int main(void){
    int n;
    long max = -1000000;
    long min = 1000000;
    long sum = 0;
    cin >> n;
    int a[10010];
    for(int i = 0;i<n;i++){
        cin >> a[i];
        //cout << a[i] << " " << endl;
    }
    for(int i = 0;i<n;i++){
        if(max < a[i]){
            max = a[i];
        }
        if(min > a[i]){
            min = a[i];
        }
        
    }
    
    for(int i = 0;i<n;i++){
        sum = sum + a[i];
    }
    cout << min << " " << max << " " << sum << endl;
    
    
}



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

string s;
ll ans = 0;
int n;

void sol(ll x,ll y){
	if(x==n){
		ans+=y;
		return;
	}

	ll curr = 0;
	for(ll i=x;i<n;i++){
		curr = (10*curr)+s[i]-'0';
		//cout<<curr<<endl;
		sol(i+1,y+curr);
	}
}


int main(){

	cin>>s;

	n = s.size();

	sol(0,0);
	cout<<ans;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;

int gcd(int a, int b) {
  return b != 0 ? gcd(b, a % b) : a;
}

bool ck(int a, int b, int c)
{
	int t=b*b-4*a*c;
	for(int i=0; i*i<=t; i++)
		if(i*i==t) return true;
		
	return false;
}

int main()
{
	int a,b,c;
	while(scanf("%d%d%d", &a,&b,&c),(a||b||c))
	{
		if(b*b-4*a*c < 0 || !ck(a,b,c)) puts("Impossible");
		else
		{
			int p=2*a, r=2*a;
			int q=-(-b+sqrt(b*b-4*a*c));
			int s=-(-b-sqrt(b*b-4*a*c));
			
			int s1=gcd(p,q);
			int s2=gcd(r,s);
			
			p/=s1; q/=s1; r/=s2; s/=s2;
			
			if(p<0)
			{
				p*=-1; q*=-1;
			}
			if(r<0)
			{
				r*=-1; s*=-1;
			}
			
			
			if(p<r || (p==r&&q<s))
			{
				swap(p,r);
				swap(q,s);
				swap(s1,s2);
			}
			printf("%d %d %d %d\n", p,q,r,s);
		}
	}
}

Measured memory_bytes: 0
N = int(input().strip())
s = [input() for i in range(N)]
ac=0
wa=0
tle=0
re=0


for i in range(N):
    if(s[i]=="AC"):
        ac=ac+1
    elif(s[i]=="WA"):
        wa=wa+1
    elif(s[i]=="TLE"):
        tle=tle+1
    else:
        re=re+1
print("AC x "+str(ac))
print("WA x "+str(wa))
print("TLE x "+str(tle))
print("RE x "+str(re))

Measured memory_bytes: 16248
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using ll = long long;
using namespace std;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

string S;
int main(){
    cin >> S;
    string ans;
    rep(i,sz(S)-1) if(S[i]==S[i+1]){
        cout << i + 1 << " " << i + 2 << '\n';
        return 0;
    }
    rep(i,sz(S)-2) if(S[i]==S[i+2]){
        cout << i + 1 << " " << i + 3 << '\n';
        return 0;
    }
    cout << "-1 -1" << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>


int main(){
  string w; cin >> w;
  map<char,int> s;
  rep(i,w.size()) s[w[i]]++;

  int flag = 0;
  for (auto p: s) flag += (p.second%2==1);

  cout << (flag==0 ? "Yes" : "No") << endl; 
  // cout << fixed << setprecision(6);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug(...)
#include <complex.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;


int32_t main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int n , t;
    cin >> n >> t;
    ll ans = 0;
    ll pv = 0;
    for(int i = 0; i < n; i++){
        int x; cin >> x;
        if(x <= pv){
            ans -= (pv - x);
        }
        ans += t;
        pv = x + t;
    }
    cout << ans << '\n';



    return 0;
}













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

int main() {
  string S;
  cin >> S;

  if (S.size() < 5) {
    puts("NO");
    return 0;
  }

  reverse(S.begin(), S.end());

  string s1 = "dream", s2 = "dreamer", s3 = "erase", s4 = "eraser";
  reverse(s1.begin(), s1.end());
  reverse(s2.begin(), s2.end());
  reverse(s3.begin(), s3.end());
  reverse(s4.begin(), s4.end());

  string T = "";

  int n = S.size();
  int i = 0;
  while (i < n) {
    if (i + 5 <= n && (S.substr(i, 5) == s1 || S.substr(i, 5) == s3)) {
      i += 5;
      continue;
    }
    if (i + 6 <= n && S.substr(i, 6) == s4) {
      i += 6;
      continue;
    }
    if (i + 7 <= n && S.substr(i, 7) == s2) {
      i += 7;
      continue;
    }

    puts("NO");
    return 0;
  }

  puts("YES");
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define st(vvv) sort(vvv.begin(),vvv.end())
#define rvs(vvv) reverse(vvv.begin(),vvv.end())
int inf = 1000000007;
i64 giant = 4000000000000000000;

using namespace std;


i64 gcd(i64 a, i64 b) {//a>bとすること
	i64 r = a % b;
	if (r == 0)return b;
	return gcd(b, r);
}

i64 lcm(i64 a, i64 b) {
	return a * b / gcd(a, b);
}


int main() {
	i64 a, b, c, d;
	cin >> a >> b >> c >> d;
	a--;
	i64 unta, untb;
	unta = (a / c) + (a / d) - (a / lcm(c, d));
	untb = (b / c) + (b / d) - (b / lcm(c, d));
	i64 ans = b - a - (untb - unta);
	cout << ans << endl;
	return 0;
}

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

using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define ll long long
#define li long int
#define ld long double
#define lld long long double

#define pb push_back
#define mk make_pair
#define F first
#define S second

#define all(v) (v).begin(),(v).end()
#define fill(a) memset(a, 0, sizeof(a))

const int MX = 1e6;
const int MI = -1e6;
const int MOD = 1e9 + 7;
const string ALPHA = "abcdefghijklmnopqrstuvwxyz";
const double PI = 3.1415926535;

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

const int mod=1e9+7;
inline int add(int x,int y)
{
  x+=y;
  if (x>=mod)
    return x-mod;
  return x;
}
inline int sub(int x,int y)
{
  x-=y;
  if (x<0)
    return x+mod;
  return x;
}
inline int mul(int x,int y)
{
  return (x*1ll*y)%mod;
}
inline int power(int x,int y)
{
  int ans=1;
  while(y)
    {
      if (y&1) ans=mul(ans,x);
      x=mul(x,x);
      y>>=1;
    }
  return ans;
}
inline int inv(int x)
{
  return power(x,mod-2);
}
inline int gcd(int x, int y)
{
  return(y!=0)?gcd(y, x%y):x;
}
inline ll nPr(int n, int r)
{
  ll i,result=1;
  rep(i,r)
    {
      result*=(ll)(n-i);
    }
  return result;
}
inline ll nCr(int n,int r)
{
  ll i,result=1;
  rep(i,min(r,n-r))
    {
      result*=(ll)(n-i);
      result/=(ll)(i+1);
    }
  return result;
}
bool prime(int n)
{
  for (int i=2; i<n/2; i++)
    {
      if(n%i==0)
	return false;
    }
  return true;
}

/*------------CODE-----------*/

int main()
{
  IOS;
  ll n;
  cin >> n;
  ll ans=0, q=100;
  while (q<n)
    {
      q+=q/100;
      ans++;
    }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 3608
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
 


public class Main {
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static long mod =1000000007;
	//static 	ArrayList<Integer> cc = new ArrayList<>(100);
	public static void main(String[] args) {
		int N=sc.nextInt();
		Map<String, Integer> map = new HashMap<String, Integer>(100001);
		for(int i=0;i<N;i++) {
			
			String t=sc.next();
			if(map.containsKey(t))map.remove(t);
			else map.put(t, 1);
			
		
			
			
			
			
		}
		int ans=0;
		for ( String key : map.keySet() ) {
			ans++;
		}
		
		p(ans);
	}
	
	
	
	
	/*static boolean v(int i,long sum1,long sum2) {
		if(i==N) {
			long b=Math.abs(sum1-sum2);
			if(b==0) {
				if(sum1<=K) {
					return true;
				}else return false;
			}else if(b%D==0) {
				if(Math.max(sum1, sum2)<=K)return true;
				else return false;
			}
			else return false;
		}
		
		if(v(i+1,sum1,sum2+v[i]%D))return true;
		
		if(v(i+1,sum1+D-v[i]%D,sum2))return true;
		return false;
		
	}*/
	
	
	
	
	

	


	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	public static int gcd(int a, int b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
}
	


Measured memory_bytes: 53424
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin>>S;
  int N=S.size();
  int count=0;
  for(int i=0;i<N;i++){
    if(S.at(i)=='0'){
      count=count+1;
    }
  }
  cout<<2*min(N-count,count)<<endl;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<stdbool.h>

int main(void)
{
    int n;
    if (scanf("%d", &n));

    int i;
    long long int sum = 0;
    for (i=1; i<=n; i++) {
        if (!(i % 3)) continue;
        if (!(i % 5)) continue;
        sum += i;
    }

    printf("%lld", sum);
    return 0;
}

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

int main(){
  int N;
  cin>>N;
  vector<int> d(N);
  for(int i=0;i<N;i++){
    cin>>d.at(i);
  }
  int s=0;
  for(int i=0;i<N-1;i++){
    for(int j=i+1;j<N;j++){
      s=s+d.at(i)*d.at(j);
    }
  }
  cout<<s<<endl;
}

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

void dfs(set<int> X, set<int> Y, int cost[10], int c[10][10])
{
    if (Y.empty())
    {
        return;
    }

    for (auto itr = Y.begin(); itr != Y.end(); itr++)
    {
    }
}

int main()
{
    int H, W;
    cin >> H >> W;

    int c[10][10];
    for (int i = 0; i < 10; i++)
    {
        for (int j = 0; j < 10; j++)
        {
            cin >> c[i][j];
        }
    }

    int count[10] = {};
    int A;
    for (int i = 0; i < H * W; i++)
    {
        cin >> A;
        if (A >= 0)
        {
            count[A]++;
        }
    }

    for (int i = 0; i < 10; i++)
    {
        for (int j = 0; j < 10; j++)
        {
            for (int k = 0; k < 10; k++)
            {
                c[j][k] = min(c[j][k], c[j][i] + c[i][k]);
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < 10; i++)
    {
        ans += c[i][1] * count[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import math
 
A, B, H, M = map(int, input().split())
 
th_h = 360 // 12 * H + 360 / 12 / 60 * M
th_m = 360 // 60 * M
 
ans = A ** 2 + B ** 2 - 2*A*B*math.cos(math.radians(abs(th_h - th_m)))
print(math.sqrt(ans))

Measured memory_bytes: 9504
use std::io::*;
use std::str::FromStr;

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 a = read::<u32>();
    let b = read::<u32>();
    let c = read::<u32>();

    println!(
        "{}",
        if a + b == c || b + c == a || c + a == b {
            "Yes"
        } else {
            "No"
        }
    );

    // match a + b == c || b + c == a || a + c == b {
    //     true => println!("YES"),
    //     false => println!("NO"),
    // };
}


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

using namespace std;

const int MAX_SIZE = 1e5 + 10;

bool alive[MAX_SIZE];
vector< int > cor;
int main()
{
	int N;
	cin >> N;
	alive[0] = false;
	int x;
	for(int i = 1; i <= N; i++)
	{
		alive[i] = true;
		cin >> x;
		if(x == i)
		{
			cor.push_back(i);
		}
	}
	int ans = 0;
	for(auto &i : cor)
	{
		if(!alive[i])
			continue;
		ans += 1;
		alive[i] = false;
		// if(!alive[i - 1])
		// {
		alive[i + 1] = false;
		// }
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using VVV = vector<VV>;
using VVVll = vector<VVll>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for (int i = (m); i < (n); ++i)
#define drep2(i, m, n) for (int i = (m)-1; i >= (n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) (a).begin(), (a).end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline int sz(T &x) { return x.size(); }
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << '(' << p.first << ", " << p.second << ')'; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int fLog2(const int x) { assert(x > 0); return 31-__builtin_clz(x); } // floor(log2(x))
inline int fLog2(const ll x) { assert(x > 0); return 63-__builtin_clzll(x); }
inline int cLog2(const int x) { assert(x > 0); return (x == 1) ? 0 : 32-__builtin_clz(x-1); } // ceil(log2(x))
inline int cLog2(const ll x) { assert(x > 0); return (x == 1) ? 0 : 64-__builtin_clzll(x-1); }
inline int popcount(const int x) { return __builtin_popcount(x); }
inline int popcount(const ll x) { return __builtin_popcountll(x); }
void fail() { puts("IMPOSSIBLE"); exit(0); }
// const int INF  = 1<<30;
// const ll INFll = 1ll<<62;
// const ld EPS   = 1e-10;
// const ld PI    = acos(-1.0);
// const int MOD  = int(1e9)+7;
// const int MOD  = 998244353;


int main() {
  int n; cin >> n;
  VV G(n);
  rep2(i, 1, n) {
    int u; cin >> u;
    --u;
    G[u].push_back(i);
  }
  V x(n); cin >> x;

  auto dfs = [&] (auto &&self, int u) -> P {
    bitset<5001> dp;
    dp[0] = 1;
    int sum = 0;
    for (int v : G[u]) {
      auto [a, b] = self(self, v);
      dp = dp<<a | dp<<b;
      sum += a + b;
    }
    drep(i, x[u]+1) if (dp[i]) return P{x[u], sum - i};
    fail();
    return P{0, 0};
  };

  dfs(dfs, 0);
  cout << "POSSIBLE\n";
  return 0;
}


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


typedef long long ll;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
/*--------------------------------------------*/

int main(){
 //cout.precision(10);
 cin.tie(0);
 ios::sync_with_stdio(false);
  
  int N;
  cin >> N;
  string s;
  cin >> s;
  
  int a[10];    //最初に現れる場所
  int b[10];
   
  rep(i,10){
    a[i] = -1;
    b[i] = -1;
  }
  
  rep(i,N){
    if(a[s[i]-'0'] == -1){
      a[s[i]-'0'] = i;
    }
  }
  
  
  for(int i = N-1;i>=0;i--){
    if(b[s[i]-'0'] == -1){
      b[s[i]-'0'] = i;
    }
  }

  /*rep(i,10){
	cout << a[i] << endl;
  }
  rep(i,10){
	cout << b[i] << endl;
  }*/
  
  int ans = 0;
  vector<int> c(10);
  
  rep(i,10){   //左の数字
    rep(j,10){  //右の数字
      if(a[i] == -1 || a[j] == -1 || a[i] >= b[j]) continue;
        c.assign(10,0);
        for(int k = a[i]+1;k < b[j];k++){
          if(c[s[k]-'0'] == 0){
            c[s[k]-'0'] = 1;
          }
        }
      ans += accumulate(ALL(c),0);
    }
  }

    
  cout << ans << endl;
}


Measured memory_bytes: 384
#include <stdio.h>
s[100],i,c=0;
main(n)
{
float w,t;
while(~scanf("%d,%f,%f",&n,&w,&t))
if(w/(t*t)>=25)s[c++]=n;
if(c==1)printf("ツ該ツ督鳴づ按つオ");
for(i=0;i<c;i++)printf("%d\n",s[i]);
return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

int H, W, K;
char s[300][300];
int ans[300][300];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> H >> W >> K;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> s[i][j];
    }
  }

  // 横に切る
  int num = 1;
  bool first = true;
  for (int i = 0; i < H; i++) {
    int j = 0;
    bool appear = false;
    while (j < W) {
      if (!appear && s[i][j] == '#') {
        j = 0;
        if (first) {
          first = false;
        } else {
          num++;
        }
        appear = true;
      }
      ans[i][j] = num;
      j++;
    }
  }

  // 縦に切る
  int h = 0;
  num = 1;
  while (h < H) {
    int h1 = h;
    int n = ans[h][0];
    while (h + 1 < H && n == ans[h + 1][0]) {
      h++;
      n = ans[h][0];
    }
    bool first = true;
    int j = 0;
    while (j < W) {
      bool appear = false;
      for (int i = h1; i <= h; i++) {
        if (!appear && s[i][j] == '#') {
          if (first) {
            first = false;
          } else {
            i = h1;
            num++;
            appear = true;
          }
        }
        ans[i][j] = num;
      }
      j++;
    }
    h++;
    num++;
  }

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (j != 0) {
        cout << " ";
      }
      cout << ans[i][j];
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1280
/*suri_kumkaran*/

#include <bits/stdc++.h>

using namespace std;

#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define MP make_pair
#define EB emplace_back
#define endl "\n"
#define PI 3.1415926535897932384626433832795
#define MOD 998244353
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long

typedef long long int64;
typedef vector<int> VI64;
typedef vector<pair<int,int>> VII64;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;

int a[3001];
int dp[3001][3001];
int32_t main()
{
	IOS;
	int T=1;
	//cin>>T;
	while(T--)
	{
		int n,s,i,j;
		cin>>n>>s;
		for(i=1;i<=n;i++)
			cin>>a[i];
		int ans=0;
		for(i=1;i<=n;i++)
		{
			for(j=0;j<=s;j++)
			{
				dp[i][j]=dp[i-1][j];
				if(j-a[i]>=0)
				{
					dp[i][j]+=dp[i-1][j-a[i]];
					dp[i][j]%=MOD;
				}
			}
			dp[i][a[i]]+=i;
			dp[i][a[i]]%=MOD;
			ans=(ans+dp[i][s])%MOD;
		}
		cout<<ans<<endl;
	}

	return 0;
}

Measured memory_bytes: 70656
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin >> n;
  int i;
  int flag = 0;
  for(i=1;i<10;i++)
  {
    if(n%i==0)
    {
      int k = n /i;
      if(k>=1 && k <= 9)
      {
        flag = 1;
        break;
      }
    }
  }
  if(flag)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
    
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
inline int read()
{
	int ret=0,f=1;
	char p=getchar();
	while(!isdigit(p)) f=p=='-'?-1:1,p=getchar();
	while(isdigit(p)) ret=(ret<<3)+(ret<<1)+p-'0',p=getchar();
	return ret*f;
}
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(b-a==c-b) cout<<"YES";
	else cout<<"NO";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <ctime>
#include <unordered_map>
#include <unordered_set>
#include <sstream>
#include <set>
#include <list>
#include <queue>
#include <utility>
#include <algorithm>
#include <functional>
#include <bitset>
#include <array>
#include <stdlib.h>
#include <thread>
#include <chrono>
#include <map>
#include <set>
#include <stdio.h>
#include <math.h>
#include <fenv.h>
using namespace std;

long long cal(int *a, int n)
{
    int cur = 1;
    long long res = 0;
    for(int i=0; i<n; ++i)
    {
        //std::cout << a[i] << std::endl;
        if(a[i]<cur)
            continue;
        if(a[i] == cur)
        {
            ++cur;
            continue;
        }
        int cnt = (a[i]-1)/cur;
        res += cnt;
        if(cur == 1)
            cur = 2;
    }
    return res;
}

int main()
{
    int n;
    std::cin>>n;
    int *a = new int[n];
    for(int i=0; i<n; ++i)
        cin>>a[i];
    
    long long res = cal(a, n);
    delete []a;
    std::cout << res << std::endl;
    
    return 0;
}


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

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

    map<int, int> appear;
    for(int i = 0; i < n; i++){
        cin >> a;
        appear[a]++;
    }

    int del = 0, two = 0;
    for(pair<int,int> p : appear){
        if(p.second == 1)   continue;
        while(p.second >= 3){
            del+=2;
            p.second -= 2;
        }
        if(p.second == 2)   two++;
    }

    del += ((two+1)/2) * 2;

    cout << n - del << endl;

    return 0;
}

Measured memory_bytes: 4992
mod = 10**9 + 7

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

B = [0] * 60
C = [0] * 60

for a in A:
    for j in range(60):
        if (a >> j) & 1:
            B[j] += 1
        else:
            C[j] += 1

ans = 0

for j in range(60):
    ans += (1 << j) * B[j] * C[j]

ans %= mod
print(ans)

Measured memory_bytes: 122936
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a;i<n;i++)
#define ve vector
#define ss second 
#define ff first
#define pf pop_front
#define pob pop_back
#define psf push_front
#define res(x) cout<<x<<'\n'
#define read(t) ll t;cin>>t

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
    string s;
    cin>>s;
    if(s=="AAA"||s=="BBB"){
        cout<<"No"<<endl;
    }
    else{
        cout<<"Yes"<<endl;
    }
    
    


   

}

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

using namespace std;

typedef vector<int> VI;
const int N = 1e3 + 5;
int _w;

int dat[N] , n , m , _mx , _mn , ans[N] , cur , vis[N] , vis_t;
VI inf;

VI solve( int len ) {
  static int dat[N];
  if( cur + len - n < 0 ) return inf;
  if( cur + len > m ) return inf;
  _mx = 0 , _mn = 0x3f3f3f3f , ++vis_t;
  memcpy( dat + 1 , ::dat + 1 , sizeof( int ) * n );
  for( int i = cur + len - n + 1 ; i <= cur ; ++i ) vis[ans[i]] = vis_t;
  for( int i = 1 ; i <= n ; ++i ) {
    if( vis[i] ^ vis_t ) {
      if( dat[i] == 0 ) return inf;
      --dat[i];
    }
    _mx = max( _mx , dat[i] );
    _mn = min( _mn , dat[i] );
  }
  if( _mn * 2 + 1 < _mx ) return inf;
  if( _mn * 2 >= _mx ) {
    VI res;
    for( int i = 1 ; i <= n ; ++i ) if( vis[i] ^ vis_t ) res.push_back( i );
    return res;
  }
  VI a , b , c;
  for( int i = 1 ; i <= n ; ++i ) if( (vis[i]^vis_t) && dat[i] == _mx ) a.push_back( i );
  for( int i = 1 ; i <= n ; ++i ) if( (vis[i]^vis_t) && dat[i] == _mn ) a.push_back( i );
  for( int i = 1 ; i <= n ; ++i ) if( (vis[i]^vis_t) && (dat[i]^_mn) && (dat[i]^_mx) ) b.push_back( i );
  int p = 0 , q = 0;
  while( p < a.size() && q < b.size() ) 
    if( a[p] < b[q] ) c.push_back( a[p++] );
    else c.push_back( b[q++] );
  while( p < a.size() ) c.push_back( a[p++] );
  while( q < b.size() ) c.push_back( b[q++] );
  int fi = 0 , se = 0;
  for( int i = cur + len - n + 1 ; i <= cur ; ++i ) {
    if( dat[ans[i]] == _mn && !se ) se = i;
    if( dat[ans[i]] == _mx ) fi = i;
  }
  for( int i = 0 ; i < c.size() ; ++i ) {
    if( dat[c[i]] == _mn && !se ) se = i + cur + 1;
    if( dat[c[i]] == _mx ) fi = i + cur + 1;
  }
  if( fi > se ) return inf;
  return c;
}

int main( void ) {
  _w = scanf("%d",&n); _mx = 0 , _mn = 0x3f3f3f3f;
  inf = VI( n , n );
  for( int i = 1 ; i <= n ; ++i ) _w = scanf("%d",dat+i) , m += dat[i] , _mx = max( _mx , dat[i] ) , _mn = min( _mn , dat[i] );
  if( _mn * 2  < _mx ) {
    puts("-1");
    return 0;
  }
  int l;
  VI res;
  while( cur < m ) {
    res = inf;
    for( l = n ; l ; --l ) {
      VI tmp = solve( l );
      if( res > tmp ) res = tmp;
    }
    for( const int & v : res )
      ans[++cur] = v , --dat[v];
  }
  for( int i = 1 ; i <= m ; ++i )
    printf("%d ",ans[i]);
  return 0;
}


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

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

const long long MOD = 1e9 + 7;
const int INF = 1e9;

int main() {
    int N;
    cin >> N;
    vector<ll> A(N + 1, 0);
    rep(i, N) {
        ll a;
        cin >> a;
        A[i + 1] += A[i] + a;
    }
    ll ans = ((ll)1 << 60);
    REP(i, 1, N) {
        ll snuke = A[i];
        ll arai  = A[N] - A[i];
        ans = min(ans, abs(snuke - arai));
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
s=input()
zerofirst="0"
onefirst="1"
for i in range(1,len(s)):
  if i%2!=0:
    zerofirst=zerofirst+"1"
    onefirst=onefirst+"0"
  else:
    zerofirst=zerofirst+"0"
    onefirst=onefirst+"1"
zerodif=0
onedif=0
for j in range(len(s)):
  if s[j]!=zerofirst[j]:
    zerodif+=1
  if s[j]!=onefirst[j]:
    onedif+=1
print(min(zerodif,onedif))

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int h, w;
string a[100];

struct E { int t, c, r; };
vector<E> g[202];
bool used[202];
const int INF = 10000;

void add(int f, int t, int c) {
	int gt = g[t].size();
	int gf = g[f].size();
	g[f].PB({ t, c, gt });
	g[t].PB({ f, 0, gf });
}

int dfs(int v, int t, int f) {
	if(v == t) { return f; }
	
	used[v] = true;
	inc(i, g[v].size()) {
		E & e = g[v][i];
		if(! used[e.t] && e.c > 0) {
			int d = dfs(e.t, t, min(f, e.c));
			if(d > 0) {
				e.c -= d;
				g[e.t][e.r].c += d;
				return d;
			}
		}
	}
	
	return 0;
}

int main() {
	cin >> h >> w;
	inc(i, h) { cin >> a[i]; }
	
	int si, sj, ti, tj;
	inc(i, h) {
	inc(j, w) {
		if(a[i][j] == 'S') { si = i; sj = j; }
		if(a[i][j] == 'T') { ti = i; tj = j; }
		if(a[i][j] == 'o') {
			add(0 + i, h + j, 1);
			add(h + j, 0 + i, 1);
		}
	}
	}
	
	int S = h + w;
	int T = S + 1;
	add(S, 0 + si, INF);
	add(S, h + sj, INF);
	add(0 + ti, T, INF);
	add(h + tj, T, INF);
	
	int ans = 0;
	while(true) {
		inc(i, 202) { used[i] = false; }
		int f = dfs(S, T, INF);
		ans += f;
		if(f == 0) { break; }
	}
	
	if(ans >= INF) { ans = -1; }
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 896