akhauriyash/Code-Regression huggingface dataset:
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }
void Taka() { cout << "Takahashi" << endl; }
void Aoki() { cout << "Aoki" << endl; }
void digit(int d) { cout << fixed << setprecision(d); }
void IOup() { cin.tie(0); ios::sync_with_stdio(false); }

int main() {
	string s;
	cin >> s;
	s[3] = '8';
	cout << s << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using pll=pair<ll,ll>;
 
const ll MOD=1000000007;

int main(){
  ll i,j,k,l,cnt=0;
  ll n,a,b;
  cin>>n>>a>>b;
  int t[n];
  for(i=0;i<n;i++)cin>>t[i];
  for(i=0;i<n;i++){
    if(t[i]<a || b<=t[i])cnt++;
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpii = vector<pll>;

int main(){
  ll a, b;
  cin >> a >> b;

  if(a * b % 2 == 0){
    cout << "Even" << endl;
  } else{
    cout << "Odd" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

string S;
int x, y;
bool dpx[8001][16010] = {{0}};
bool dpy[8001][16010] = {{0}};

int main(void){
    
    cin >> S;
	scanf("%d %d", &x, &y);
	x += 8000, y += 8000;
	
	vector<int> vx, vy;
	int cnt = 0, sum = 0;
	for(int i = 0; i < S.size(); ++i){
	    if(S[i] == 'T'){
	        ++cnt;
	        if(sum == 0) continue;
	        (cnt % 2 == 1) ? vx.push_back(sum) : vy.push_back(sum);
	        sum = 0;
	    }
	    else ++sum;
	}
	(cnt % 2 == 0) ? vx.push_back(sum) : vy.push_back(sum);
	
	for(int i = 0; i < vx.size(); ++i){
	    if(i){
	        for(int j = 0; j < 16010; ++j){
	            if(dpx[i - 1][j]) dpx[i][j - vx[i]] = true;
	            if(dpx[i - 1][j]) dpx[i][j + vx[i]] = true;
	        } 
	    }
	    else dpx[0][8000 + vx[i]] = (S.front() == 'T') ? dpx[0][8000 - vx[i]] = true : true;
	}
	
	for(int i = 0; i < vy.size(); ++i){
	    if(i){
	        for(int j = 0; j < 16010; ++j){
	            if(dpy[i - 1][j]) dpy[i][j - vy[i]] = true;
	            if(dpy[i - 1][j]) dpy[i][j + vy[i]] = true;
	        } 
	    }
	    else dpy[0][8000 + vy[i]] = dpy[0][8000 - vy[i]] = true;
	}
	dpx[0][8000] = dpy[0][8000] = true;
	
	int a = (vx.size()) ? vx.size() - 1 : 0, b = (vy.size()) ? vy.size() - 1 : 0;
	if(dpx[a][x] && dpy[b][y]) printf("Yes\n");
	else printf("No\n");
	
    return 0;
}


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

#define for(i, a, b) for(ll (i)=a;(i)<(b);++(i))
#define rep(i, n)    for(i, 0, n)

const ll inf = 1e15;
const ll mod = 1e9+7;

int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};

int main() {
    ll x;
    cin >> x;
    
    ll cnt = 2 * (x / 11);
    
    x %= 11;
    if (x > 0) {
        cnt += x <= 6 ? 1 : 2;
    }
    
    cout << cnt << endl;
    
    return 0;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
constexpr long long INF = 1000000000000000;

long long N;
long long h[100000];
long long min_cost[100000];


int main(void) {
  scanf("%lld", &N);

  rep(i,N) scanf("%lld",h+i);
  rep(i,N-1) min_cost[i+1] = INF;

  rep(i,N) {
    min_cost[i + 1] = min(min_cost[i + 1], min_cost[i] + abs(h[i + 1] - h[i]));
    min_cost[i + 2] = min(min_cost[i + 2], min_cost[i] + abs(h[i + 2] - h[i]));
  }

  printf("%lld\n", min_cost[N - 1]);

  return 0;
}

Measured memory_bytes: 1664
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader is = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(is);
		String line = br.readLine();
		int x=Integer.parseInt(line);
		System.out.println((int)Math.pow(x, 3));
	}
}

Measured memory_bytes: 24248
#include <bits/stdc++.h>
using namespace std;
int main(){
  int X;
  cin >> X;
  bool check = true;
  for(int i=X;check;i++){
    if(i <= 3){
      cout << i << endl;
    check = false;
    continue;
    }
    bool fin = true;
    for(int j=2;j*j <= X;j++){
      if(i % j == 0){
        fin = false;
      }
    }
    if(fin){
      cout << i << endl;
      check = false;
    }
  }
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
total = sum(a)
total_a, total_b = 0, 0
i = 0
while total_a + a[i] <= total / 2:
    total_a += a[i]
    i += 1
i = n - 1
while total_b + a[i] <=  total / 2:
    total_b += a[i]
    i -= 1

print(total - max(total_a, total_b) * 2)

Measured memory_bytes: 26220
N = gets.to_i

class Vertex
  attr_accessor :x, :y
  def initialize(x, y)
    @x = x.to_f
    @y = y.to_f
  end

  # -v1
  def -@
    Vertex.new(@x * (-1), @y * (-1))
  end

  # v1 + v2
  def +(v)
    Vertex.new((@x + v.x), (@y + v.y))
  end

  # v1 - v2
  def -(v)
    Vertex.new((@x - v.x), (@y - v.y))
  end

  # v1 * 2
  def *(i)
    Vertex.new(@x * i, @y * i)
  end

  # v1 / 3
  def /(i)
    Vertex.new(@x / i, @y / i)
  end

  def rotate(rad)
    Vertex.new(Math.cos(rad) * @x - Math.sin(rad) * @y,
               Math.sin(rad) * @x + Math.cos(rad) * @y)
  end
end

class Edge
  attr_accessor :start_vertex, :end_vertex
  def initialize(start_vertex, end_vertex)
    @start_vertex = start_vertex
    @end_vertex = end_vertex
  end

  def two_vertex_to_five
    v1 = @start_vertex
    v5 = @end_vertex
    v2 = (v1 * 2 + v5) / 3
    v4 = (v1 + v5 * 2) / 3
    v3 = v2 + (v4 - v2).rotate(Math::PI / 3)
    [v1,v2,v3,v4,v5]
  end

  # [Edge, Edge, Edge, Edge, Edge]
  def divide
    vertexes = two_vertex_to_five
    vertexes[0..-2].zip(vertexes[1..-1]).map {|v1, v2| Edge.new(v1, v2)}
  end
end


class KochCurve
  def initialize(n)
    @n = n
    @edges = [Edge.new(Vertex.new(0, 0), Vertex.new(100, 0))]
    create_koch_curve
  end

  def create_koch_curve
    @n.times do
      @edges = @edges.map(&:divide).flatten
    end
    @edges
  end

  def vertexes # [Vertex, Vertex, ]
    @edges.map {|edge| edge.start_vertex} + [Vertex.new(100, 0)]
  end
end

koch_curve = KochCurve.new(N)
koch_curve.vertexes.each do |vertex|
  puts "#{vertex.x} #{vertex.y}"
end


Measured memory_bytes: 7020
# util functions
class UnionFind
  def initialize(n) # n: number of elements in the forest
    @grps = n
    @par  = []
    @rank = []
    @vs   = []  
    n.times do |i|
      @par[i] = i
      @rank[i] = 0
      @vs[i] = 1
    end
  end
  attr_accessor :par, :rank, :vs, :grps

  def find(x)
    raise "x = #{x} is out of range 0..#{@par.size - 1}" unless @par[x]
    if @par[x] == x
      return x
    else
      return find( @par[x] )
    end
  end

  def unite( x, y )
    xrt = find(x)
    yrt = find(y)
    return if xrt == yrt

    @grps -= 1
    
    if @rank[xrt] > @rank[yrt]
      @par[yrt] = xrt
      @vs[xrt] += @vs[yrt]
    else
      @par[xrt] = yrt
      @vs[yrt] += @vs[xrt]
      @rank[yrt] += 1 if @rank[xrt] == @rank[yrt]
    end
  end

  def same( x, y ) # returns true/false
    return find( x ) == find( y )
  end

end # UnionFind


# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if false
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

nn = inputs[0][0]
mm = inputs[0][1]

# body
if $debugFlag
  p nn
  p mm
end

uf = UnionFind.new(nn)

for i in 0..mm-1
  uf.unite(inputs[i+1][0]-1, inputs[i+1][1]-1)
end

# pd uf.par
# pd uf.rank
# pd uf.vs
puts uf.grps


Measured memory_bytes: 12044
// D.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <numeric>

using namespace std;

int main(int argc, char* argv[]) {
#ifdef _MSC_VER
	while (true)
#endif
	{
		int n = -1, m = -1, ans = 0;
		cin >> n >> m;
		if (n < 0) return 0;
		vector<int> x(n);
		vector<vector<int>> mods(m);
		for (int i = 0; i < n; ++i) {
			cin >> x[i];
			mods[x[i] % m].push_back(x[i]);
		}
		for (int i = 0; i <= m / 2; ++i) {
			if (i == 0 || i * 2 == m) {
				ans += (int)mods[i].size() / 2;
			} else {
				vector<int> a = mods[i];
				vector<int> b = mods[m - i];
				if (a.size() < b.size()) {
					swap(a, b);
				}
				int remain = (int)(a.size() - b.size());
				sort(a.begin(), a.end());
				for (int j = 1; j < (int)a.size(); ++j) {
					if (remain <= 1) break;
					if (a[j - 1] == a[j]) {
						remain -= 2;
						++ans;
						++j;
					}
				}
				ans += (int)b.size();
			}
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 6144
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, int> pli;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

typedef struct UnionFindTree{
    vector<int> par;

    UnionFindTree(int n){
        par.resize(n, -1);
    }

    bool is_root(int x){
        return par[x]<0;
    }

    int find(int x){
        if(is_root(x)) return x;
        return par[x] = find(par[x]);
    }

    int size(int x){
        return -par[find(x)];
    }

    bool unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y) return false;
        if(size(x) < size(y)) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    bool same(int x, int y){
        return find(x) == find(y);
    }
}UF;

int main(){
    int n, m, K;
    scanf("%d%d%d", &n, &m, &K);
    UF uf(n);
    vector<int> G[n];
    rep(i, m){
        int a, b;
        scanf("%d%d", &a, &b);
        --a; --b;
        G[a].push_back(a);
        G[b].push_back(b);
        uf.unite(a, b);
    }

    int ans[n];
    rep(i, n) ans[i] = uf.size(i) - 1 - (int)G[i].size();
    rep(i, K){
        int c, d;
        scanf("%d%d", &c, &d);
        --c; --d;
        if(uf.same(c, d)){
            --ans[c];
            --ans[d];
        }
    }
    rep(i, n) printf("%d ", ans[i]);
}

Measured memory_bytes: 7416
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int count;
  for (int i = 0; i < 30; i++){
    for (int j = 0; j < 30; j++){
      if (4 * i + 7 * j == N){
        count++;
      }
    }
  }
  if(count) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  int arr[N + 2];
  int skip_dist[N];
  int normal_dist[N];
  int num;
  for (int i = 0; i < N; i++){
      cin >> num;
      arr[i + 1] = num;
  }
  arr[0] = 0;
  arr[N + 1] = 0;

  int sum_dist = 0;

  for (int i = 0; i < N + 1; i++){
      int base_point = i + 1;
      sum_dist += abs(arr[base_point - 1] - arr[base_point]);
  }

  for (int i = 0; i < N; i++){
      int base_point = i + 1;
      int skip_distance = abs(arr[base_point - 1] - arr[base_point + 1]);
      int normal_dist = abs(arr[base_point - 1] - arr[base_point]) + abs(arr[base_point] - arr[base_point + 1]);
      cout << sum_dist - (normal_dist - skip_distance) << endl;
  }

  return 0;
}

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

int main() {
  
  int n, x;
  cin >> n >> x;
  
  vector<int> m(n);
  
  int min = 1000;
  for(int i = 0; i < n; i++) {
    cin >> m.at(i);
    x -= m.at(i);
    if(min > m.at(i))
      min = m.at(i);
  }
  
  int more = 0;
  more = x / min;
  
  cout << n + more << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

int main(){
    string s;
    while(cin >> s){
        if( (s[0]==s[1] && s[1]==s[2]) && (s[0]=='o' || s[0]=='x')  ) cout << s[0] << endl;
        else if( (s[3]==s[4] && s[4]==s[5]) && (s[3]=='o' || s[3]=='x') ) cout << s[3] << endl;
        else if( (s[6]==s[7] && s[7]==s[8]) && (s[6]=='o' || s[6]=='x') ) cout << s[6] << endl;
        else if( (s[0]==s[3] && s[3]==s[6]) && (s[0]=='o' || s[0]=='x') ) cout << s[0] << endl;
        else if( (s[1]==s[4] && s[4]==s[7]) && (s[1]=='o' || s[1]=='x') ) cout << s[1] << endl;
        else if( (s[2]==s[5] && s[5]==s[8]) && (s[2]=='o' || s[2]=='x') ) cout << s[2] << endl;
        else if( (s[0]==s[4] && s[4]==s[8]) && (s[0]=='o' || s[0]=='x') ) cout << s[0] << endl;
        else if( (s[2]==s[4] && s[4]==s[6]) && (s[2]=='o' || s[2]=='x') ) cout << s[2] << endl;
        else cout << 'd' << endl;
    }
    return 0;
}


Measured memory_bytes: 3156
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

void inverse(int n,vector<ll> &inv){
    //要素数:n+1
    inv[1]=1;
    for(int i=2;i<=n;i++){
        inv[i]=(MOD-inv[MOD%i]*(MOD/i))%MOD;
    }
}



int main() {
    int n,dis; cin>>n;
    vector<int> me(n+1,-1);
    int ad;
    rep(i,n+1){
        cin>>ad;
        if(me[ad]>=0){
            dis=i-me[ad]+1; break;
        }
        else{
            me[ad]=i;
        }
    }
    vector<ll> v(n+2,0);
    inverse(n+1,v);
    
    ll c=1,d=1;
    rep(i,n+1){
        c=((c*(n+1-i))%MOD)*v[i+1]%MOD;
        c=(c+MOD)%MOD;
        cout<<(c-d+MOD)%MOD<<endl;
        d=((d*(n+1-dis-i))%MOD)*v[i+1]%MOD;
        d=(d+MOD)%MOD;
    }
}

Measured memory_bytes: 2432
#include<iostream>
#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define vi vector<int>
#define lvi vector<long long>
#define pi pair<int,int>
#define lpi pair<long long ,long long>
#define mp make_pair
#define pb push_back
#define ll long long 
#define faltu ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mod 1000000007
#define mod1 1000000000000000007
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>multiordered_set;
ll int pw(ll int a, ll int b,ll md) {
    if (b == 0) return 1;
    ll int t = pw(a, b / 2,md);
    if (b % 2 == 0) return (t * t)%mod;
    else return ((t * t)%mod * a)%mod;
}
vector<int> pm;
void prm(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));
    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
              prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p]) pm.push_back(p);
}
bool cmp(const pair<ll int,ll int> &a,const pair<ll int,ll int> &b)
{
    if(a.first==b.first)return a.second<b.second;
    return a.first>b.first;
}
ll int gcd(ll int a,ll int b)
{
    if(!a)return b;
    return gcd(b%a,a);
}
bool isPrime(int n) 
{ 
    if (n <= 1) 
        return false; 
    for (int i = 2; i < n; i++) 
        if (n % i == 0) 
            return false; 
    return true; 
} 
map<int,int>pa;
int find(int i){
    if(pa[i]==i)return i;
    return pa[i]=find(pa[i]);
}     
void join(int i,int j){
    int a=find(i);
    int b=find(j);
    if(b>=a)pa[b]=a;
    else pa[a]=b;
}               
int ddx[]={-1,-1,-1,0,1,1,1,0};
int ddy[]={-1,0,1,1,1,0,-1,-1};
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};
int main()
{
    faltu;
    int t=1;
   // cin>>t;
    while(t--)
    {
        int a[3];
        cin>>a[0]>>a[1]>>a[2];
        sort(a,a+3);
        if(a[0]==5&&a[1]==5&&a[2]==7)cout<<"YES";
        else cout<<"NO";
    }
}

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

int main() { 
    int N,K;
    int R,S,P;
    string T;
	cin >> N >> K;
	cin >> R >> S >> P;
	cin >> T;

    int res = 0;
    int cont = 0;
    string output = T;

    for (int i = 0; i < K; i++) {
        if(T[i] =='r'){
            output[i] = 'p';
            res += P;
        } else if(T[i] =='p') {
            output[i] ='s';
            res += S;
        } else {
            output[i] = 'r';
            res += R;
        }
    }
    for(int i = K; i < N; i++){
        if (T[i] == 'r') {
            if(output[i-K] == 'p') {
                output[i] = 'x';
            } else {
                output[i] = 'p';
                res += P;
            }
        } else if(T[i] == 'p') {
            if(output[i-K] == 's'){
                output[i] = 'x';
            } else {
                output[i] = 's';
                res += S;
            }
        } else {
            if (output[i-K] == 'r'){
                output[i] = 'x';
            } else {
                output[i] = 'r';
                res += R;
            }
        }
    }
    cout << res << " " << endl;
	return 0;
}   

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		
		int[] numbers = new int[N];
		for (int i = 0; i < N; i++) {
			numbers[i] = scan.nextInt();
		}
		
		int count = 0;
		for (int i = 1; i <= numbers.length; i++) {
			if (numbers[i - 1] == i) {
				count++;
			}
		}
		
		if (count >= (N - 2)) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
		
	}
}

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

int main()
{
  string s;
  
  cin>>s;
  
  if(s[s.size()-1]!='s')
  {
    cout<<s<<'s';
  }
  else
  {
    cout<<s<<"es";
  }
  
  return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(ll i=0;i<n;++i)
#define ocut cout
#define ouct cout
#define itn int
ll gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

ll lcm(int a, int b)
{
   return a * b / gcd(a, b);
}
struct Union{
  vector<ll> par;
  Union(ll a){
  par=vector<ll>(a,-1);
  }
  ll find(ll a){
    if(par[a]<0){
      return a;
    }
    else{
      return par[a]=find(par[a]);
    }
  }
  bool same(ll a,ll b){
    return (find(a)==find(b));
  }
  ll size(ll a){
    return -par[find(a)];
  }
  void unite(ll a,ll b){
    ll c=find(a),d=find(b);
    if(c==d)
      return;
    if(size(c)<size(d)){
      swap(c,d);
    }
    par[c]+=par[d];
    par[d]=c;
  }
};
int main(){
  ll n;
  cin >> n;
  cout << (n/500)*1000+((n%500)/5)*5;
}

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

using namespace std;

void solve()
{
    string s;
    while (cin >> s)
    {
        if (s == "-")
        {
            return;
        }
        int n = s.size(), l = 0;
        s += s;
        int m, h;
        cin >> m;
        while (m--)
        {
            cin >> h;
            l += h;
            if (l >= n)
            {
                l -= n;
            }
        }
        for (int i = 0; i < n; i++)
        {
            cout << s[i + l];
        }
        cout << '\n';
    }
}

int main()
{
    solve();
    return 0;
}



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

using namespace std;
#define ll long long
#define sint(a) scanf("%d",&a)
#define sint2(a,b) scanf("%d %d",&a,&b)
#define sll(a) scanf("%lld",&a)
#define sll2(a,b) scanf("%lld %lld",&a,&b)
#define mem(a,i) memset(a,i,sizeof(a))
#define pb push_back
const double pi=acos(-1);
const int mod=1e9+7;
const int maxn=1e6+10;
//int a[maxn],sum;
//int d[maxn];
//int c;
//int dfs(int v,int k)
//{
//    if(k==s)
//    {
//
//    }
//    for(int i=v+1;i<sum;i++)
//    {
//        if(a[v]+c<a[i])
//        {
//            b[i]=1;
//            dfs(a[i],k+1);
//            b[i]=0;
//        }
//
//    }
//}
int a[maxn];
int main()
{
    int n;
    cin>>n;
    int w=1;
    a[1]=1;
    a[0]=1;
    for(int i=1; i<n; i++)
    {
        int isok=0;
        for(int j=w; j>0; j--)
            if(a[j]!=9)
                isok=1;
        if(!isok)
        {
            w++;
            a[1]=1;
            for(int k=2; k<=w; k++)
                a[k]=0;
        }
        else
        {
            for(int j=w; j>0; j--)
            {
                if(a[j]>a[j-1]||a[j]==9)
                {
                    continue;
                }
                else
                {
                    a[j]+=1;
                    if(j==1)
                        a[0]=a[j];
                    for(int k=j+1; k<=w; k++)
                        a[k]=a[k-1]==0?0:a[k-1]-1;
                    break;
                }
            }
        }
    }
    for(int i=1; i<=w; i++)
        printf("%d",a[i]);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <set>
#define INF 1e8

using namespace std;
int main(){
  int n,m;
  while(cin>>n>>m,n||m){
    vector<vector<int> > g(n);
    for(int i=0;i<n;++i){
      g[i].reserve(n);
      for(int j=0;j<n;++j) g[i][j]=INF;
    }
    for(int i=0,a,b,cost;i<m;++i){
      cin>>a>>b>>cost;
      g[a][b]=cost;
      g[b][a]=cost;
    }
    int ans=0;
    set<int> v;
    v.insert(0);
    while(v.size()!=n){
      int min_cost=INF,to=0;
      for(set<int>::iterator vit=v.begin();vit!=v.end();++vit){
        for(int i=0;i<n;++i){
          if(v.find(i)==v.end()&&g[*vit][i]<min_cost){
            to=i;
            min_cost=g[*vit][i];
          }
        }
      }
      ans+=min_cost;
      v.insert(to);
    }
    cout<<ans<<endl;
  }
  return 0;
}

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

long long solve(long long n) {
	long long ans = 0, tmp = n;
	while (tmp > 9) {
		long long last = tmp % 10;
		if (last < 9) {
			ans += 9;
			tmp -= last;
			tmp -= 1;
			tmp /= 10;
		} else {
			ans += 9;
			tmp /= 10;
		}
	}

	ans += max(0LL, tmp);

	return ans;
}

int main() {

	long long n;
	cin >> n;

	long long ans = solve(n);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int c[4]={}, c1[4]={1, 1, 2, 2};
	for(int i=0; i<3; i++){
		int a, b; cin>>a>>b;
		a--; b--;
		c[a]++; c[b]++;
	}
	sort(c, c+4);
	for(int i=0; i<4; i++){
		if(c[i]!=c1[i]){
			cout<<"NO"<<endl;
			return 0;
		}
	}
	cout<<"YES"<<endl;

	return 0;
}

Measured memory_bytes: 256
N = int(input())
X = list(map(int, input().split()))

pos = sorted([v for v in X if v >= 0])
neg = sorted([v for v in X if v < 0], reverse=True)

ans = []
if not neg:
    # neg is empty
    cnt = pos[0]
    for v in pos[1:-1]:
        ans.append((cnt, v))
        cnt -= v
    ans.append((pos[-1], cnt))
    print(pos[-1] - cnt)
elif not pos:
    # pos is empty
    cnt = neg[0]
    for v in neg[1:]:
        ans.append((cnt, v))
        cnt -= v
    print(cnt)
else:
    # neg and pos exist
    for v in pos[:-1]:
        ans.append((neg[0], v))
        neg[0] -= v

    cnt = pos[-1]
    for v in neg:
        ans.append((cnt, v))
        cnt -= v
    print(cnt)

for v in ans:
    print(*v)


Measured memory_bytes: 100828
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#include <set>
#include <iterator>
using namespace std;
using namespace __gnu_pbds;


#define f first
#define s second
#define pb push_back
#define all(x) x.begin(),x.end()

#define ll long long int
#define vi vector<int>
#define vii vector<pair<int,int> >
#define pii pair<int,int>
#define plii pair<pair<ll, int>, int>
#define piii pair<pii, int>
#define viii vector<pair<pii, int> >
#define vl vector<ll>
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define mp make_pair
#define ms(x, v) memset(x, v, sizeof x)
#define pr_vec(v) for(int i=0;i<v.size();i++) cout << v[i] << " " ;

#define f_in(st) freopen(st,"r",stdin)
#define f_out(st) freopen(st,"w",stdout)

#define INF INT_MAX
#define matrix vector<vector<ll> >

#define fr(i, a, b) for(i=a; i<=b; i++)
#define fb(i, a, b) for(i=a; i>=b; i--)
#define ASST(x, l, r) assert( x <= r && x >= l )
#define maxbits 9
#define maxmask (1ll<<maxbits)
typedef tree<pll, null_type, less<pll>, rb_tree_tag,
             tree_order_statistics_node_update>
    new_data_set;
const int  N=100000 +10, M=(ll)1e9+1 ;
const int mod =998244353 ,sz=5 ;

void work(){
  ll n;
  cin >> n;
  vl a(n);
  for(ll i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  ll ans=0;
  double cur=1.0*a[0];
  for(int i=1;i<n;i++){
    cur=(cur+a[i])/2.0;
  }
  cout << fixed << setprecision(5) << cur;
    
}
int main(){
 ios_base::sync_with_stdio(0);
 cin.tie(0);
    ll t;
    // cin >> t;
    t=1;
    while(t--){
            work();
    }
   return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int a,b,c;
 cin>>a>>b>>c;
 
 if(a==b){
 	cout<<c<<endl;
 }
 else if(a==c){
 	cout<<b<<endl;
 }
 else{
 	cout<<a<<endl;
 }
 	
 
 return 0;
 }

Measured memory_bytes: 256
n,k = gets.chomp.split(" ").map(&:to_i)
x_arr = gets.chomp.split(" ").map(&:to_i)

min = (10 ** 8) * 3
(0..(n - k)).each do |i|
  left = x_arr[i]
  right = x_arr[k - 1 + i]
  if left <= 0 && right <= 0
    d = left.abs
  elsif left >= 0 && right >= 0
    d = right.abs
  elsif left.abs > right.abs
    d = right.abs * 2 + left.abs
  else
    d = left.abs * 2 + right.abs
  end
  min = d if d < min
end

puts min


Measured memory_bytes: 21736
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

long long abso(long long n){
    if (n < 0){
        n = -1 * n;
    }
    return n;
}

int main(){

    int N, M;
    cin >> N >> M;

    vector <long long> X(N), Y(N), Z(N);

    for (int i = 0; i < N; i++){
        cin >> X[i] >> Y[i] >> Z[i];
    }
    
    long long ans = 0;

    for (int i = 0; i < 8; i++){
        int p = i;
        int a, b, c;
        a = p % 2;
        p = p / 2;
        b = p % 2;
        c = p / 2;
        
        vector <long long> sum(N);

        for (int j = 0; j < N; j++){
            sum[j] = X[j] * pow(-1, a) + Y[j] * pow(-1, b) + Z[j] * pow(-1, c);
        }

        sort(sum.begin(), sum.end());
        long long s = 0;
        for (int j = 0; j < M; j++){
            s += sum[N - 1 -j];
        }
        if (s > ans){
            ans = s;
        }
    }
    

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<map>
#include<set>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<chrono>
#include<stack>
#include<fstream>
#include<list>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define SIZE(a) ll(a.size())
#define vll vector<ll> 
#define MEMSET(a, n, m) for(ll i=0;i<=n;i++) a[i] = m
#define BIT(n) (ll(1)<<n)
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end()) 
#define UNIQUE_ARRAY(a,n) n = unique(a + 1, a + x + 1) - a - 1
#define SORT(a,n) sort(a+1,a+n+1)
#define SORT_O(a,n,order) sort(a+1,a+n+1,order)
#define PER(i,y,x) for(ll i=y;i>=x;i--)
typedef long long ll;
using namespace std;

/*
struct point
{
long long dist; long long name;
bool operator<(const point& rhs) const {
return dist > rhs.dist;
}
};
*/

ll const MAX = 1e5 + 5;
ll dp[105][MAX] = {};
ll w[105], v[105];

int main() {
	ll n, W;
	cin >> n >> W;
	REP(i, 1, n) {
		cin >> w[i] >> v[i];
	}
	REP(i, 0, n) {
		dp[i][0] = 0;
	}
	REP(j, 1, W) {
		dp[0][j] = -1e18;
	}
	REP(i, 1, n) {
		REP(j, 1, W) {
			if (j < w[i]) {
				dp[i][j] = dp[i - 1][j];
			}
			else {
				dp[i][j] = max(dp[i - 1][j],v[i] + dp[i - 1][j - w[i]]);
			}
		}
	}
	ll ans = 0;
	REP(i, 0, W) {
		ans = max(ans, dp[n][i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 80128
/*
[agc035] B - Even Degrees
*/

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

const int MAX_N = 1e5;
const int MAX_M = 1e5;

int N, M;
int A[MAX_M], B[MAX_M];
vector<int> g[MAX_N];
bool visited[MAX_N];

void dfs(int v, int par = -1) {
    if (visited[v]) {
        return;
    }
    visited[v] = true;

    int par_e = -1;
    int cnt = 0;
    for (int e : g[v]) {
        int to = A[e] != v ? A[e] : B[e];
        if (to == par) {
            par_e = e;
            continue;
        }
        dfs(to, v);
    }
    for (int e : g[v]) {
        if (v == A[e]) {
            cnt++;
        }
    }
    if (par_e != -1 && cnt % 2 != 0) {
        swap(A[par_e], B[par_e]);
    }
}

void solve() {
    if (M % 2 != 0) {
        cout << -1 << endl;
        return;
    }

    for (int i = 0; i < M; i++) {
        g[A[i]].push_back(i);
        g[B[i]].push_back(i);
    }

    dfs(0);

    for (int i = 0; i < M; i++) {
        cout << A[i] + 1 << " " << B[i] + 1 << endl;
    }
}

int main() {
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        cin >> A[i] >> B[i];
        A[i]--, B[i]--;
    }

    solve();

    return 0;
}


Measured memory_bytes: 15488
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll po(const ll p, const ll n, const ll mod)
{
    if (n == 0) { return 1; }
    if (n % 2 == 1) {
        return po(p, n - 1, mod) * p % mod;
    } else {
        const ll pp = po(p, n / 2, mod);
        return pp * pp % mod;
    }
}
constexpr ll inv(const ll p, const ll mod) { return po(p, mod - 2, mod); }
constexpr ll BASE1 = 186398169LL;
constexpr ll MOD1 = 1000000007LL;
constexpr ll INV1 = inv(BASE1, MOD1);
constexpr ll BASE2 = 238173201LL;
constexpr ll MOD2 = 1000000009LL;
constexpr ll INV2 = inv(BASE2, MOD2);
constexpr int MAX = 100000;
P power[MAX], inverse[MAX], h[MAX];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    for (ll i = 0, p1 = 1, p2 = 1, i1 = 1, i2 = 1, h1 = 0, h2 = 0; i < S.size(); i++, (p1 *= BASE1) %= MOD1, (p2 *= BASE2) %= MOD2, (i1 *= INV1) %= MOD1, (i2 *= INV2) %= MOD2) { (h1 += (S[i] - 'a') * p1 % MOD1) %= MOD1, (h2 += (S[i] - 'a') * p2 % MOD2) %= MOD2, h[i] = {h1, h2}, inverse[i] = {i1, i2}, power[i] = {p1, p2}; };
    auto add = [](const P& p1, const P& p2) -> P { return {(p1.first + p2.first) % MOD1, (p1.second + p2.second) % MOD2}; };
    auto sub = [](const P& p1, const P& p2) -> P { return {(p1.first + MOD1 - p2.first) % MOD1, (p1.second + MOD2 - p2.second) % MOD2}; };
    auto mul = [](const P& p1, const P& p2) -> P { return {(p1.first * p2.first) % MOD1, (p1.second * p2.second) % MOD2}; };
    auto getHash = [&](const int s, const int l) -> P { return l == 0 ? P{0, 0} : s == 0 ? h[s + l - 1] : mul(sub(h[s + l - 1], h[s - 1]), inverse[s]); };
    int Q;
    cin >> Q;
    for (int q = 0; q < Q; q++) {
        int l, r, t;
        (cin >> l >> r >> t), l--;
        const int L = r - l;
        int inf = 0, sup = L - t;
        while (sup - inf > 1) {
            const int mid = (inf + sup) / 2;
            if (getHash(l, mid) == getHash(l + t, mid)) {
                inf = mid;
            } else {
                sup = mid;
            }
        }
        bool ok = false;
        for (int i = 0; i < 26; i++) {
            for (int j = 0; j < 2; j++) {
                const int pos = j == 0 ? inf : inf + t;
                const P ch = sub({i, i}, {S[pos + l] - 'a', S[pos + l] - 'a'});
                const P off1 = (pos < L - t ? power[pos] : P{0, 0});
                const P off2 = (pos >= t ? power[pos - t] : P{0, 0});
                if (add(getHash(l, L - t), mul(off1, ch)) == add(getHash(l + t, L - t), mul(off2, ch))) {
                    ok = true;
                    break;
                }
            }
        }
        cout << (ok ? "Yes\n" : "No\n");
    }
}



Measured memory_bytes: 8024
#include<bits/stdc++.h>
using namespace std; 
#define mod 1000000007
#define N 100005
#define ll long long
#define ull unsigned long long
#define loop1(i, j, k, step) for (int i=j; i<k; i+=step)
#define loop(i, j, k) for (int i=j; i<k; i++) 
#define rloop1(i, j, k, step) for (int i=j; i>=k; i-=step)
#define rloop(i, j, k) for(int i=j; i>=k; i--)
#define rep(i, k) for(int i = (0); i < (k); i++ )
#define rrep(i, k) for(int i = k-1; i >= 0; i-- )

#define forall(it, l) for(auto it=l.begin(); it != l.end(); it++)
#define mp make_pair
#define pb push_back
#define pop pop_back
#define F first
#define S second
#define sz(x) (int)(x).size()
#define endl "\n"
#define Max (int)INT_MAX
#define Min (int)INT_MIN
#define MEM(a, b) memset(a, (b), sizeof(a))
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;


void solve()
{
	int n,i,j,k,l;
	string s,s1;
	cin>>s>>s1;
	string s2=s1.substr(0,sz(s1)-1);
	if(s==s2)
		cout<<"Yes\n";
	else
		cout<<"No\n";
}
int  main() 
{
	auto start=clock();
	fast_io;
    int t=1;
    //cin>>t;
    while(t--)
    	solve();
    auto stop =clock();
    cerr<<"time taken:"<<double(stop-start)/double(CLOCKS_PER_SEC)<<" s"<<endl;
	return 0; 
}

Measured memory_bytes: 3844
c1=list(map(int,input().split()))
c2=list(map(int,input().split()))
c3=list(map(int,input().split()))
c=[c1,c2,c3]
for i in range(2):
    if c[i][0]-c[i+1][0]!=c[i][1]-c[i+1][1] or c[i][1]-c[i+1][1]!=c[i][2]-c[i+1][2]:
        print("No")
        exit()
for j in range(2):
    if c[0][i+1]-c[0][i]!=c[1][i+1]-c[1][i] or c[1][i+1]-c[1][i]!=c[2][i+1]-c[2][i]:
        print("No")
        exit()
print("Yes")


Measured memory_bytes: 3064
#include <iostream>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
//const int MAX=;

int main(){
	int c[2];
	cin>>c[0]>>c[1];
	int K;
	cin>>K;
	rep(i,K){
		int p=i%2;
		int q=(i+1)%2;
		if(c[p]%2){
			c[p]-=1;
		}
		c[p]/=2;
		c[q]+=c[p];
	}
	cout<<c[0]<<' '<<c[1];
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	bool f=0;
	int x;
	cin>>s;
	for(int i=0;i<s.size();i++){
		if(s[i]=='C')f=1;
		if(s[i]=='F'&&f==1){
			cout<<"Yes";return 0;
		}
	}
	cout<<"No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 10000000000000009
//#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ORREP(i,n) for(int i=(n);i>=1;--i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl


signed main(){
    int N,K;
    cin >> N >> K;
    YES(2*K-1<=N);
    return 0;
}

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

namespace ABC131A
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var tmp = s[0];
            bool isDifficult = false;
            for(int i = 1; i < s.Length; i++)
            {
                if(tmp == s[i])
                {
                    isDifficult = true;
                    break;
                }
                tmp = s[i];
            }
            if (isDifficult)
            {
                Console.WriteLine("Bad");
            }
            else
            {
                Console.WriteLine("Good");
            }
        }
    }
}


Measured memory_bytes: 13140
a = gets.to_i
b = gets.to_i
c = gets.to_i
x = gets.to_i

sum = 0

for i in 0..a do
  for j in 0..b do
    for k in 0..c do
      way = i*500 + j*100 + k*50
      if way == x
        sum += 1
      end
    end
  end
end

puts sum


Measured memory_bytes: 2044
#include<iostream>
#include<vector>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
typedef long long ll;

int main(){
    int H, W, N;
    cin >> H >> W >> N;
    vector<int> a(N);
    vector<int> tmp(W);
    rep(i,N) cin >> a[i];
    int k=0;
    for(int i=0; i<H; i++){
        if(i%2==0){
            for(int j=0; j<W; j++){
                if(a[k]!=0){
                    cout << k+1 << " ";
                    a[k]--;
                }else{
                    k++;
                    cout << k+1 << " ";
                    a[k]--;
                }
            }
            cout << endl;
        }else{
            for(int j=W-1; j>=0; j--){
                if(a[k]!=0){
                    tmp[j] = k+1;
                    a[k]--;
                }else{
                    k++;
                    tmp[j] = k+1;
                    a[k]--;
                }
            }
            for(int j=0; j<W; j++){
                cout << tmp[j] << " ";
            }
            cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
int main() {
  int n;cin>>n;
  int  l;cin>>l;
  int ans;
  
  if(l>=0){
    
    ans = (l+1+l+n-1)*(n-1)/2;
    cout << ans << endl;
    return 0;
  }
  else {
    if(l+n>0){
      ans = (l+l+n-1)*(n)/2;
      cout << ans<< endl;
      return 0;
    }
    ans = (l+l+n-2)*(n-1)/2;
   
    cout << ans << endl;
    return 0;
  }
}

Measured memory_bytes: 256
#include <cstdio>

long long GCD(long long a, long long b) {
	if (a % b != 0)return GCD(b, a % b);
	else return b;
}

int main() {
  long long A, B;
  scanf("%lld%lld", &A, &B)+1;
  
  printf("%lld\n", A / GCD(A, B) * B);
  
  return 0;
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
using namespace std;

typedef pair<int, int> pii;
typedef long long ll;


const int BIG_NUM = 1e8;
const ll INF = 1000000000000000000;

const int ALPHABET = 26;

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

	
	stack<char> s;
	while (n > 0) {
		int num = n % ALPHABET;
		num--;
		n /= ALPHABET;

		if (num < 0) {
			num = ALPHABET - 1;
			n--;

		}
		s.push('a' + num);
		
	}
	

	while (!s.empty()) {
		cout << s.top();
		s.pop();
	}
}

Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>

template <class T>
struct SegmentTree {
    using Merger = std::function<T(T, T)>;

    int length;
    std::vector<T> dat;
    T unit;
    Merger merge;

    explicit SegmentTree(int n, T unit, Merger merge)
        : length(1), unit(unit), merge(merge) {
        while (length < n) length <<= 1;
        dat.assign(length * 2, unit);
    }

    T query(int ql, int qr) {
        ql = std::max(ql, 0);
        qr = std::min(qr, length);
        ql += length, qr += length;

        T lacc = unit, racc = unit;
        while (ql < qr) {
            if (ql & 1) {
                lacc = merge(lacc, dat[ql]);
                ++ql;
            }
            if (qr & 1) {
                --qr;
                racc = merge(dat[qr], racc);
            }
            ql >>= 1, qr >>= 1;
        }
        return merge(lacc, racc);
    }

    void update(int nidx, T elem) {
        nidx += length;
        dat[nidx] = elem;

        while (nidx > 0) {
            nidx >>= 1;
            T vl = dat[nidx * 2 + 0];
            T vr = dat[nidx * 2 + 1];
            dat[nidx] = merge(vl, vr);
        }
    }
};

void solve() {
    int n;
    std::cin >> n;

    std::vector<SegmentTree<int>>
        segs(26, SegmentTree<int>(n, 0,
                                  [&](auto a, auto b) { return a + b; }));
    for (int i = 0; i < n; ++i) {
        char c;
        std::cin >> c;
        segs[c - 'a'].update(i, 1);
    }

    int q;
    std::cin >> q;
    while (q--) {
        int t;
        std::cin >> t;

        if (t == 1) {
            int i;
            char c;
            std::cin >> i >> c;
            --i;

            for (auto& seg : segs) seg.update(i, 0);
            segs[c - 'a'].update(i, 1);
        } else {
            int l, r;
            std::cin >> l >> r;
            --l;

            int ans = 0;
            for (auto& seg : segs) ans += (seg.query(l, r) > 0);
            std::cout << ans << std::endl;
        }
    }
}

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

    solve();

    return 0;
}


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

int main()
{
    string n;
    cin >> n;
    int cnt = 0;
    for (int i = 0; i < n.size(); i++)
    {
        if (n[i] == '9')
        {
            cnt++;
        }
    }
    if (cnt > 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

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

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define F first
#define S second
#define pb push_back
#define pii pair <int, int>
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define reunique(a) (a).resize(unique(all(a)) - (a).begin())
#define ld long double
#define int long long

int vis[100500];
int used[100500];
int ans[100500];
vector <int> g[100500];
set <int> bad[100500];
set <int> comp;
set <int> suki;
int ct;

void dfs(int v){
    vis[v] = 1;
    ct++;
    comp.insert(v);
    for (auto u : g[v]){
        if (vis[u]) continue;
        dfs(u);
    }
}
void dfs1(int v){
    used[v] = 1;
    for (auto u : bad[v]){
        if (comp.count(u))
            ans[u]--;
    }
    for (auto u : g[v]){
        if (used[u]) continue;
        dfs1(u);
    }
}

void SOLVE(){
    int n, m, k;
    cin >> n >> m >> k;
    for (int i = 0; i < m; i++){
        int v, u;
        cin >> v >> u;
        v--, u--;
        g[v].pb(u);
        g[u].pb(v);
    }
    for (int i = 0; i < k; i++){
        int v, u;
        cin >> v >> u;
        v--, u--;
        bad[v].insert(u);
        bad[u].insert(v);
    }
    for (int i = 0; i < n; i++){
        if (!vis[i]){
            comp.clear();
            ct = 0;
            dfs(i);
            dfs1(i);
            for (auto now : comp){
                ans[now] += ct - g[now].size() - 1;
                ans[now] = max(0LL, ans[now]);
            }
        }
    }
    for (int i = 0; i < n; i++){
        cout << ans[i] << ' ';
    }
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(12);
    int Q = 1;
    //cin >> Q;
    while (Q--){
        SOLVE();
    }

    return 0;
}




Measured memory_bytes: 28276
import sys

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG: {} -> {}'.format(name, val), file=sys.stderr)
            return None

x = int(input())

ans = (x // 11) * 2
x %= 11

if x > 0:
    if x > 6:
        ans += 2
    else:
        ans += 1

print(ans)

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

ll X;

int main(){
    cin >> X;

    for(int i=-120;i<120;i++){
        for(int j=-120;j<120;j++){
            if (pow(i, 5)-pow(j, 5) == X){
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 4100
# AtCoder Beginner Contest 104 B
S = input()
if S[0] == 'A' and S[2:-1].count('C') == 1:
  C_pos = S[2:-1].find('C') + 2
  S_changed = 'a' + S[1:C_pos] + 'c' + S[C_pos+1:]
  if S_changed.islower():  
    print('AC')
  else:
    print('WA')  
else:
  print('WA')


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <limits>
#include <cmath>

using namespace std;

int main() {
    size_t n;
    cin >> n;
    cout << (n + 1) / 2 << endl;
    return 0;
}


Measured memory_bytes: 256