akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
typedef long long ll;

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

  int ans = 0;

  int N = S.size();


    rep(i,N/2){
      if (S[i] != S[N-i-1]) {
        ans++;
      }
    }  


    cout << ans << endl;
    return 0;
}


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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main()
{
	int N, M, K;

	cin >> N >> M >> K;
	bool flag = false;
	fx(N+1) {
		fy(M+1) {
			if (M*x+y*N == K + x*y*2) {
				flag = true;
				x = N; y = M;
			}
		}
	}

	if (flag) {
		ce("Yes")
	}
	else {
		ce("No")
	}

    return 0;
}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<cmath>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>
using namespace std;
#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define ALL(x) (x).begin(),(x).end()
#define dump(x) cout << (x) << endl
#define LMAX 9223372036854775807LL
#define LMIN -9223372036854775807LL
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
vector<int> g[114514];
bool used[114514];
int main() {
	IOS;
	ll n, m;
	cin >> n >> m;
	REP(i, m) {
		int a, b;
		cin >> a >> b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	deque<int> que;
	que.push_front(1);
	que.push_back(g[1][0]);

	fill(used, used + n, false);
	
	used[1] = used[g[1][0]] = true;
	while (1) {
		bool ok = true;
		REP(i, g[que.front()].size()) {
			if (!used[g[que.front()][i]]) {
				used[g[que.front()][i]] = true;
				que.push_front(g[que.front()][i]);
				ok = false;
				break;
			}
		}
		REP(i, g[que.back()].size()) {
			if (!used[g[que.back()][i]]) {
				used[g[que.back()][i]] = true;
				que.push_back(g[que.back()][i]);
				ok = false;
				break;
			}
		}
		if (ok)break;
	}
	dump(que.size());
	REP(i, que.size()) {
		cout << que[i] << ' ';
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 7168
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define sz(v) (int)v.size() 
#define all(v) v.begin(), v.end()
void dbg_out() { cerr << "\b\b]\n"; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T){ cerr << H << ", "; dbg_out(T...);}
#define watch(...) cerr << "[" << #__VA_ARGS__ << "]: [", dbg_out(__VA_ARGS__)


/****************************** CODE IS HERE ***********************************/
int d;
vector <int> num;
const int mod = 1e9 + 7;
ll dp[10004][103][2];


ll go(int pos, int rem, int tight) {
    if (pos == sz(num)) {
        return !rem;
    }
    if (dp[pos][rem][tight] != -1) return dp[pos][rem][tight];

    int limit = (tight ? num[pos] : 9);
    ll ans = 0;
    for (int i = 0; i <= limit; ++i) {
        int newtight = tight;
        if (i < limit) newtight = 0;
        (ans += go(pos+1, (rem + i) % d, newtight)) %= mod;
    }
    return dp[pos][rem][tight] = ans;
}

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

    string s; cin >> s >> d;
    for (char i: s) {
        num.push_back(i - '0');
    }
    memset(dp, -1, sizeof dp);

    ll ans = go(0, 0, 1) % mod;
    ans = (ans - 1 + mod) % mod;          //becuz 000...0 is not allowed
    cout << ans;

    return 0;
}


Measured memory_bytes: 20740
#include <bits/stdc++.h>
using namespace std;
int n;
int a[200009];
int vis[200009];
int k;
int main()
{
    cin>>n>>k;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=1;i<=n;i++)
        vis[a[i]]++;
    sort(vis,vis+200000);
    int ans=0;
    for(int i=0;i<200000-k;i++)
        ans+=vis[i];
    cout<<ans;
}


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

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

	vector<vector<int>> dp( N + 1, vector<int>( 3 ) );
	for( int i = 0; i < N; i++ ) {
		int flag = 0;
		for( int j = 0; j < 3; j++ ) {
			if( flag == 0 && dp[i][j] == A[i] ) {
				flag = 1;
				dp[i + 1][j] = dp[i][j] + 1;
			}
			else dp[i + 1][j] = dp[i][j];
		}
	}
	const long long MOD = 1000000000 + 7;
	long long ans = 1;
	for( int i = 0; i < N; i++ ) {
		int n = 0;
		int a = A[i];
		for( int j = 0; j < 3; j++ ) {
			if( dp[i][j] == a ) n++;
		}
		ans = ans * n % MOD;
	}

	cout << ans << endl;
}


Measured memory_bytes: 6144
#include <iostream>
#include <string>
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
int main()
{
    int n; cin >> n;
    while (n--) {
        string s; cin >> s;
        string head = s.substr(0, 2);
        bool ok = true;
        if (head == ">'") {
            int c = 0;
            REP(i, 2, s.size()) { if (s[i] != '=') break; c++; }
            if (c < 1) ok = false;
            else if (s[c+2] != '#') ok = false;
            else if (s.substr(c+3, c) != string(c, '=')) ok = false;
            else if (s.size() != c*2 + 4) ok = false;
            else if (s[s.size()-1] != '~') ok = false;
            puts(ok ? "A" : "NA");
        }
        else if (head == ">^") {
            if (s.substr(2, 2) != "Q=") ok = false;
            else {
                for (int i = 4; i < s.size()-2; i+=2)
                    if (s.substr(i, 2) != "Q=") { ok = false; break; }
                if (ok && s.substr(s.size()-2) != "~~") ok = false;
            }
            puts(ok ? "B" : "NA");
        }
        else puts("NA");
    }
    return 0;
}

Measured memory_bytes: 0
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

class Main {
    public static final List<Integer> CARDS;
    static {
        List<Integer> list = new ArrayList<Integer>();
        for (int i = 1; i <= 10; i++) {
            list.add(i);
        }
        CARDS = Collections.unmodifiableList(list);
    }

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = "";
        int myFirstCard, mySecondCard, rivalCard;

        while ((line = br.readLine()) != null && ! line.isEmpty()) {
            StringTokenizer st = new StringTokenizer(line);
            myFirstCard = Integer.parseInt(st.nextToken());
            mySecondCard = Integer.parseInt(st.nextToken());
            rivalCard = Integer.parseInt(st.nextToken());

            int sum = myFirstCard + mySecondCard;
            if (sum <= 10) {
                System.out.println("YES");
                continue;
            }

            int maxCard = 20 - sum;
            int goodCardCount = 0;
            for (Integer num : CARDS) {
                if (num == myFirstCard || num == mySecondCard || num == rivalCard) {
                    continue;
                }
                if (num <= maxCard) {
                    goodCardCount++;
                }
            }

            System.out.println((goodCardCount > 3) ? "YES" : "NO");
        }
    }
}

Measured memory_bytes: 16876
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main()
{
  int n;
  cin>>n;
  vector<vector<tuple<int,int>>> vt;
  for(auto&& i:irange(0,n)) {
    int a;
    cin>>a;
    vector<tuple<int,int>> tmp;
    for(auto&& j:irange(0,a)) {
      int x,y;
      cin>>x>>y;
      tmp.emplace_back(x,y);
    }
    vt.push_back(tmp);
  }
  int mx = 0;
  for(auto&& i:irange(0,1<<n)) {
    bool ok = true;
    int cnt = 0;
    bitset<15> b = i;
    for(auto&& j:irange(0,n)) {
      if (b[j]) {
        ++cnt;
        for(auto&& t:vt[j]) {
          int x,y;
          tie(x,y) = t;
          if (b[x-1] != y) {
            ok = false;
          }
        }
      }
    }
    if (ok) {
      mx = max(mx, cnt);
    }
  }
  cout<<mx<<endl;
  return 0;
}


Measured memory_bytes: 256
def solve(n,k,x):
  d = [x[i+1]-x[i] for i in range(n-1)]
  d.sort(key=lambda e: -e)
  if k >= n:
    s = 0
  else:
    s = sum(d[k-1:n])
  return s
hoge = int(input())
for j in range (hoge):
  n,k = map(int, input().split( ))
  x = list(map(int, input().split( )))
  print(solve(n,k,x))


Measured memory_bytes: 21052
# coding: utf-8
from collections import Counter


def solve(*args: str) -> str:
    n = int(args[0])
    A = list(map(int, args[1].split()))
    counts = Counter(A)
    memo = [0]*(n+1)
    total = 0
    for i, c in counts.items():
        memo[i] = c*(c-1)//2
        total += memo[i]

    ret = []
    for a in A:
        tmp = total - memo[a] + (memo[a]*(counts[a]-2)//counts[a])
        ret.append(str(tmp))

    return '\n'.join(ret)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


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

#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b)) < EPS)

class Point                             
{
public:
	double x, y;
	Point(double x = 0, double y = 0) :x(x), y(y) {}

	Point operator + (Point p) { return Point(x + p.x, y + p.y); }
	Point operator - (Point p) { return Point(x - p.x, y - p.y); }
	Point operator * (double a) { return Point(a * x, a * y); }
	Point operator / (double b) { return Point(x / b, y / b); }

	double dot(Point a, Point b) { return a.x * b.x + a.y * b.y; }
	double abs() { return sqrt(norm()); }
	double norm(){ return x * x + y * y; }

	bool operator <(const Point &p)const { return x != p.x ? x < p.x : y < p.y; }
	bool operator == (const Point &p) const { return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS; }         
};
typedef Point Vector;              

struct Segment {                        
	Point p1, p2;
	Segment() {}
	Segment(Point p1, Point p2) :p1(p1), p2(p2) {}
};
typedef Segment Line;      

double norm(Vector a) { return a.x*a.x + a.y*a.y; } 
double abs(Vector a) { return sqrt(norm(a)); }        

double dot(Vector a, Vector b) { return a.x*b.x + a.y*b.y; }   
double cross(Vector a, Vector b) { return a.x*b.y - a.y*b.x; }

Point project(Segment s, Point p) {
	Vector base = s.p2 - s.p1;
	double r = dot(p - s.p1, base) / norm(base);
	return s.p1 + base * r;
}

int main() {                                                    
	double x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	Line base = Line(Point(x1, y1), Point(x2, y2));
	int q; cin >> q;
	while (q--) {
		cin >> x1 >> y1;
		Point p = project(base, Point(x1, y1));
		printf("%.8lf %.8lf\n",x1+2*(p.x-x1), y1+2*(p.y-y1));
	}
	return 0;
}






Measured memory_bytes: 3292
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <complex>
using namespace std;

const double Pi = acos(-1.0);
typedef long long ll;

void Read(int &p)
{
	p = 0;
	char c = getchar();
	for (; c < '0' || c > '9'; c = getchar());
	for (; c >= '0' && c <= '9'; c = getchar())p = p * 10 + c - '0';
}
struct cpx
{
	double r, i;
	cpx(){r = 0; i = 0;}
	cpx(double a, double b){r = a, i = b;}
	cpx operator + (cpx b){return cpx(r + b.r, i + b.i);}
	cpx operator - (cpx b){return cpx(r - b.r, i - b.i);}
	cpx operator * (cpx b){return cpx(r * b.r - i * b.i, r * b.i + i * b.r);}
	cpx operator *= (cpx b){return *this = *this * b;}
	cpx operator /= (double a){return *this = cpx(r / a, i / a);}
}a[1 << 22], b[1 << 22];

void DFT(cpx *A, int f, int w)
{
	for (int i = 1, j = 0; i < w; i++)
	{
		for (int d = w >> 1; j ^= d, ~j & d; d >>= 1);
		if (i < j)
			swap(A[i], A[j]);
	}
	for (int i = 1; i < w; i <<= 1)
	{
		cpx wn(cos(Pi / i), f * sin(Pi / i));
		for (int j = 0; j < w; j += i << 1)
		{
			int k = j + i;
			cpx w1(1, 0);
			for (int l = 0; l < i; l++)
			{
				cpx x = A[j + l], y = w1 * A[k + l];
				A[j + l] = x + y;
				A[k + l] = x - y;
				w1 *= wn;
			}
		}
	}
	if (f == -1)
		for (int i = 0; i < w; i++)
			A[i] /= w;
}


int n, sum;
int C[1 << 10][1 << 10];
ll ans[2100000];

int main()
{
    scanf("%d", &n);
    int w = 1, setlen = (n - 1) * (n * 2 + 1);
    while (w <= setlen * 2)w <<= 1;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
		{
			Read(C[i][j]);
			sum += C[i][j];
			ans[0] += C[i][j] * (C[i][j] - 1) / 2;
            int id = i * 2 * n + j;
			a[id].r = C[i][j];
			b[setlen - id].r = C[i][j];
		}
	DFT(a, 1, w), DFT(b, 1, w);
	for (int i = 0; i < w; i++)
		a[i] = a[i] * b[i];
	DFT(a, -1, w);
    double ans1 = 0;
    for (int i = 1; i <= setlen; i++)
	{
		ll t = (ll)(a[setlen + i].r + 0.3);
		if(!t) continue;
        int dx = ((i / n) + 1) >> 1;
        int dy = abs(i - dx * n * 2);
        ans1 += sqrt((double)dx * dx + (double)dy * dy) * t;
        ans[dx*dx+dy*dy] += t;
    }

    ans1 /= (double)sum * (sum - 1) / 2;
    printf("%.10f\n", ans1);

    int num = 0;

    int top = (n - 1) * (n - 1) * 2;
    for(int i = 0; i <= top && num < 10000; i++) if(ans[i]) {
        printf("%d %lld\n", i, ans[i]);
        num++;
    }

    return 0;
}


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

#define ll long long

int main()
{
    int N, R;
    std::cin >> N >> R;

    if(N >= 10) {
        std::cout << R << std::endl;
    }
    else {
        std::cout << R + (10-N)*100 << std::endl;
    }
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int a[100010];
int main(){
    int n;
    string s;
    while(cin>>s){
        ll ans=0;
        n=s.size();
        for(int i=0; i<n; ++i){
        	if(s[i]=='?'){
        		s[i]='D';
        	}
        	if(s[i]=='D'){
        		++ans;
        	}
        }
        // for(int i=0; i+1<n; ++i){
        // 	if(s[i]=='P' && s[i+1]=='D'){
        // 		++ans;
        // 	}
        // }
        cout<<s<<endl;
    }
  return 0;
}




Measured memory_bytes: 3756
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;


namespace StartFinish
{
 
    class Program
    {
        static void Main(string[] args)
        {
            int[] nm = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int[][] A = new int[nm[0]][];
            for(int i = 0; i < nm[0]; i++)
            {
                A[i] = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            }
            int[,] B = new int[1, nm[1]];
            for(int i = 0; i < nm[1]; i++)
            {
                B[0,i] = int.Parse(Console.ReadLine());
            }
            for(int i = 0; i < nm[0]; i++)
            {
                int sum = 0;
                for (int j = 0; j < nm[1]; j++)
                { 
                    sum += A[i][j] * B[0, j];
                }
                Console.WriteLine(sum);
            }
        }
    }
}

Measured memory_bytes: 9828
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;

#define A first
#define B second

int n, d[55];
vector<int> g[55];
int vis[55];
bool y = 0;

void dfs(int v, int c) {
	vis[v] = c;
	for (int u : g[v]) {
		if (vis[u] == 0) {
			dfs(u, 3-c);
		}

		if (vis[u] + vis[v] != 3)
			y = 1;
	}
}

bool bip() {
	for (int i = 0; i < n; ++i) {
		if (vis[i] == 0)
			dfs(i, 1);
	}

	return !y;
}

bool check(int x) {
	for (int i = 0; i < n; ++i)
		g[i].clear();
	memset(vis, 0, sizeof(vis));
	y = 0;

	for (int i = 0; i < n-1; ++i)
		if (d[i] < x)
			return 0;
	
	for (int i = 0; i < n; ++i)
		for (int j = i+1; j < n; ++j) {
			if (abs(d[i] - d[j]) < x) {
				g[i].push_back(j);
				g[j].push_back(i);
			}

			if (24-(d[i] + d[j]) < x)
				return 0;
		}

	return bip();
}

int main() {
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> d[i];
	d[n] = 0;

	n++;

	for (int i = 12; i >= 0; --i) {
		if (check(i)) {
			cout << i << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
object Main {
  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val a = sc.nextLong
    val b = sc.nextLong

    println(f(a-1)^f(b))
  }

  def f(n:Long) : Long = {
    (n+1) % 4 match {
      case 0 => 0
      case 1 => n
      case 2 => 1
      case 3 => 1^n
    }
  }

}

Measured memory_bytes: 27308
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int n=1;
  string s;
  cin>>s;
  for(int i=0;i<s.size();i++){
	if(n%2!=0){
      cout<<s[i];
    }
    n++;
  }
  cout<<"\n";
  return(0);
}

Measured memory_bytes: 512
n=int(input())
A=[list(map(int,input().split())) for i in range(n)]
B=[]
for i in range(n):
    B.append([A[i][0]-A[i][1],A[i][0]+A[i][1]])
B=sorted(B)
point=B[0][1]
a,b=1,1
for i in range(1,n):
    if B[i][0]>=point:
        point=B[i][1]
        a +=1

point=B[-1][0]
for i in reversed(range(0,n-1)):
    if B[i][1]<=point:
        point=B[i][0]
        b +=1

print(max(a,b))

Measured memory_bytes: 42208
#include <stdio.h>
int RideBack[10];
bool check(int val) {int B=-1,C=-1,q;for (q=9;q>=0;q--,val>>=1) if (val&1) {if (B<RideBack[q]) B=RideBack[q]; else break;} else {if (C<RideBack[q]) C=RideBack[q]; else break;} return (q<0);}
int main() {int N,i;scanf("%d",&N);while (N--) {for (i=9;i>=0;scanf("%d",&RideBack[i--]));for (i=0;i<1024;i++) if (check(i)) break;if (i==1024) puts("NO"); else puts("YES");}return 0;}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <math.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REPR(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define FOR(i, n, m) for (ll i = (n); i < (m); ++i)
#define FORR(i, n, m) for (ll i = (m) - 1; i >= (n); --i) 
#define FORE(x, xs) for (auto &x: (xs))
#define ALL(v) v.begin(), v.end()
#define ZERO(a) memset(a,0,sizeof(a))

const int INF = 1000000009;
const int MOD = 1000000007;
const double EPS = 1e-14;
const double PI = acos(-1);

const int MAX = 2e5;

ll N, M;
bool a[100001];
ll n[100001];

int main() {
  cin >> N >> M;
  REP (i, N+1) {
    a[i] = false;
    n[i] = 1;
  }
  a[1] = true;

  REP (i, M) {
    int x, y;
    cin >> x >> y;
    a[y] |= a[x];
    n[y]++;
    n[x]--;
    if (n[x] == 0) a[x] = false;
  }

  int ans = 0;
  REP (i, N+1) ans += a[i];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
typedef long long int ll;
typedef unsigned long long int sll;
typedef long double ld;
#define A 1000000007ll
#define D 100000000000000ll
#define B 998244353ll
#define C 1000000000000000000ll
#define M 4000
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define oset tree<pair<ll,ll>, null_type,less_equal<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> 
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define br break
#define PI acos(-1)
#define subt cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n" 

struct ret
{
    ll a[26];
};

const ll MAXN = 500005;
ret t[4*MAXN];

ll dist(ret z)
{
    ll ans=0;
    for(int i=0;i<26;i++)
        if(z.a[i]!=0)
            ans++;
    return ans;
}

ret su(ret x, ret y)
{
    ret z;
    for(int i=0;i<26;i++)
        z.a[i]=x.a[i]+y.a[i];
    return z;
}

void builds(ll ar[], ll v, ll tl, ll tr) 
{
    if (tl == tr) 
    {
        for(int i=0;i<26;i++)
            t[v].a[i]=0;
        t[v].a[ar[tl]] = 1;
    }
    else 
    {
        ll tm = (tl + tr) / 2;
        builds(ar, v*2, tl, tm);
        builds(ar, v*2+1, tm+1, tr);
        t[v] = su(t[v*2],t[v*2+1]);
    }
}

ret sum(ll v, ll tl, ll tr, ll l, ll r) 
{
    if (l > r) 
    {
        ret z;
        for(int i=0;i<26;i++)
            z.a[i]=0;
        return z;
    }
    if (l == tl && r == tr) 
        return t[v];
    ll tm = (tl + tr) / 2;
    return su(sum(v*2, tl, tm, l, min(r, tm)),sum(v*2+1, tm+1, tr, max(l, tm+1), r));
}

void updates(ll v, ll tl, ll tr, ll pos, ll new_val) 
{
    if (tl == tr) 
    {
        for(int i=0;i<26;i++)
            t[v].a[i]=0;
        t[v].a[new_val] = 1;
    }
    else 
    {
        ll tm = (tl + tr) / 2;
        if (pos <= tm)
            updates(v*2, tl, tm, pos, new_val);
        else
            updates(v*2+1, tm+1, tr, pos, new_val);
        t[v] = su(t[v*2],t[v*2+1]);
    }
}

int main() 
{
    FAST;
    ll n;
    cin>>n;
    ll a[n];
    string s;
    cin>>s;
    for(int i=0;i<n;i++)
        a[i]=s[i]-'a';
    builds(a,1,0,n-1);
    ll q;
    cin>>q;
    while(q-->0)
    {
        ll x;
        cin>>x;
        if(x==1)
        {
            ll y,z;
            char ch;
            cin>>y>>ch;
            z=ch-'a';
            updates(1,0,n-1,y-1,z);
        }
        else
        {
            ll y,z;
            cin>>y>>z;
            cout<<dist(sum(1,0,n-1,y-1,z-1))<<'\n';
        }
    }
    subt;
    return 0;
}

Measured memory_bytes: 219932
#include <iostream>
#include <string>

int main(){
    using namespace std;
    string s;
    cin >> s;
    // cout << to_string(s.size()) << endl;
    // cout << s[0];
    // cout << to_string(s[0]) + to_string(s.length() + s[s.length()]);
    // cout << s[0] + s.length() + s[s.length()];
    
    cout << s[0] << s.length() - 2<< s[s.size()-1];
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS

#include <bits/stdc++.h>
using namespace std;
#define error(args...)                       \
{                                            \
    cerr<<"LINE "<<__LINE__;                 \
    string _s = #args;                       \
    replace(_s.begin(), _s.end(), ',', ' '); \
    stringstream _ss(_s);                    \
    istream_iterator<string> _it(_ss);       \
    err(_it, args);                          \
    cerr<<endl;                              \
}
void err(istream_iterator<string> it)
{
} 
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
  cerr<<' '<< *it << " = " << a ;
  err(++it, args...);
}

typedef long long ll;
const ll MOD = 1e9 + 7;
const int N = 1e6 + 9, M = 1e6, OO = 0x3f3f3f3f;


int main()
{
  int n;
  scanf("%d",&n);
  set<int>s;
  for(int i=0;i<n;++i)
  {
    int x;
    scanf("%d",&x);
    s.insert(x);
  }
  if(s.size()==n) printf("YES");
  else printf("NO");
    
  
  #ifdef _LOCAL_DEFINE
  cerr << (double)clock() * 1.0 / CLOCKS_PER_SEC << endl;
  #endif
  return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
const long double PI=(acos(-1));
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  int n,m;
  cin>>n>>m;
  vector<int> cnt(m,0);
  for(int i=0;i<n;i++){
    int k;
    cin>>k;
    for(int j=0;j<k;j++){
      int a;
      cin>>a;
      a--;
      cnt[a]++;
    }
  }
  int ans=0;
  rep(i,m){
    if(cnt[i]==n){
      ans++;
    }
  }
  cout<<ans<<endl;
    
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner s=new Scanner(System.in);
        int n=s.nextInt();
        int a=n/10;
        n-=(a*10);
        if(n==3){
            System.out.println("bon");
        }else if(n==0||n==1||n==6||n==8){
            System.out.println("pon");
        }else{
            System.out.println("hon");
        }
    }
}


Measured memory_bytes: 35732
#include <stdio.h>

int main(){
	int i,j,k,z;
	scanf("%d %d %d",&i,&j,&k);
	for(int a=0;;){		
		if(i%2!=0){i=i-1;}
		z=i;i=i/2;j=j+z/2;a=a+1;
		
	    if(a==k) break;
		
		if(j%2!=0){j=j-1;}           
		z=j;j=j/2;i=i+z/2;a=a+1;
        
        if(a==k) break;
	}
	printf("%d %d",i,j);
}


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

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

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N, M = LI()
    used = [0 for _ in range(N)]
    cur = 0
    pairs = []
    used = set()
    if N % 2 == 0:
        a = 1
        b = N
        while len(pairs) < M:
            if b-a in used or N + a -b in used or b - a == N//2:
                b -= 1
            pairs.append((a, b))
            used.add(b-a)
            used.add(N+a - b)
            a += 1
            b -= 1

    else:
        a = 1
        b = N - 1
        while len(pairs) < M:
            pairs.append((a, b))
            a += 1
            b -= 1
    for p in pairs:
        print(p[0], p[1])



main()



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

int main(){
    int n, m;
    scanf("%d%d",&n,&m);
    int sum=0;
    int ma=max(n,m);
    int mi=min(n,m);
    sum = sum+ma;
    ma = ma-1;
    ma = max(ma, mi);
    sum = sum+ma;
    printf("%d\n", sum);

	return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

ll N, W;
vector<ll> weight(100010), value(100010);
vector<vector<ll>> memo(110, vector<ll>(100010, -1));

ll solve(ll n, ll w)
{
    if (memo.at(n).at(w) != -1)
    {
        return memo.at(n).at(w);
    }
    if (n == N)
    {
        return memo.at(n).at(w) = 0;
    }
    if (w - weight.at(n) < 0)
    {
        return memo.at(n).at(w) = solve(n + 1, w);
    }
    else
    {
        ll res1 = solve(n + 1, w);
        ll res2 = solve(n + 1, w - weight.at(n)) + value.at(n);
        return memo.at(n).at(w) = max(res1, res2);
    }
}

int main()
{
    cin >> N >> W;
    rep(0, i, N)
    {
        cin >> weight.at(i) >> value.at(i);
    }

    memo.at(0).at(0) = 0;

    cout << solve(0, W) << endl;
}

Measured memory_bytes: 91752
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
 
using namespace std;
 
using LL = long long;
using vi = vector<int>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
using vll = vector<LL>;
using LD = long double;
 
#define ALL(v) v.begin(), v.end()
#define endl '\n'
#define SYNC ios_base::sync_with_stdio(false); cin.tie(NULL); cerr.tie(NULL);
#define REP(i , n) for(int i =0 ; i < n ;i++)
#define REPN(i , n) for(int i = 1; i <= n ; i++)
#define cot(x) cerr << #x << " " << x << " ";
#define cotd(x) cerr << #x << " " << x << endl;
#define her 	cerr << " here \n"; 
#define pp push_back
#define fi first 
#define se second
#define un(x) x.erase(unique(ALL(x)), x.end())
 
template<typename T > void check(T & a, const T & b) { if (a >= b) { a %= b; } }
template<typename T>T gcd(T u, T v) { if (u == v)return u; if (u == 0)return v; if (v == 0)return u; if (~u & 1) { if (v & 1) return gcd(u >> 1, v); else return gcd(u >> 1, v >> 1) << 1; }if (~v & 1)return gcd(u, v >> 1); if (u > v)return gcd((u - v) >> 1, v); return gcd((v - u) >> 1, u); }
LL mulmod(LL a, LL b, const LL & m) { LL q = (LL)(((LD)a*(LD)b) / (LD)m); LL r = a*b - q*m; if (r>m)r %= m; if (r<0)r += m; return r; }
template <typename T, typename S>T expo(T e, S n) { T x = 1, p = e; while (n) { if (n & 1)x = x*p; p = p*p; n >>= 1; }return x; }
template <typename T>T powerL(T e, T n, const T & m) { T x = 1, p = e; while (n) { if (n & 1)x = mulmod(x, p, m); p = mulmod(p, p, m); n >>= 1; }return x; }
 
const int N = (int)1e5 + 10; 
int n, vis[N], m, col[N];
vector<vi> g; 
 
pair<bool,int> bfs(int u){
	queue<int> q; q.push(u); 
	col[u] = 1; int nodes = 0; 
	bool Bipart = true; 
 
	while(!q.empty()){
		int v = q.front(); q.pop(); 
		nodes++;   
		vis[v] = true; 
 
		for(int & i : g[v]){
			if(!vis[i]){ 
				col[i] = col[v] ^ 1; 
				q.push(i); 
			}
			else if(col[i] == col[v])
				Bipart = false;  
		}
	}
 
	return {Bipart, nodes}; 
}
 
int main(){
	SYNC; 
	cin >> n >> m; 
	g.resize(n + 1);
 
	REP(i , m){
		int u , v; cin >> u >> v; 
		u--; v--; 
		g[u].pp(v); g[v].pp(u); 
	}
 
	LL ans = 0; int leaf = 0, x = 0, y = 0;
 
	for(int i = 0; i < n; i++){
		if(!vis[i]){
			auto __x = bfs(i); 
			if(__x.se == 1)leaf++; 
			else if(__x.fi)x++; 
			else y++; 
		}
	}
 
	ans = ( 2 * leaf * 1LL * n) - (leaf * 1LL * leaf); 
	ans += (2 * x * 1LL * x) + (2 * x * 1LL * y) + ( y * 1LL * y ); 	
	cout << ans << endl; 
 
	return 0; 
}

Measured memory_bytes: 8192
-module('Main').
-export([main/1]).

main(_) ->
    {ok, [A, B]} = io:fread("", "~d ~s"),
    [BeforeDot, AfterDot|_] = string:split(B, "."),
    {BeforeDotInt, _} = string:to_integer(BeforeDot),
    {AfterDotInt, _} = string:to_integer(AfterDot),
    B100 = BeforeDotInt * 100 + AfterDotInt,
    Ans = A * B100 div 100,
    io:format("~p~n", [Ans]),
    halt().

Measured memory_bytes: 26812
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;

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

  vector<string> A(n);
  REP(i, n) cin >> A[i];
  int B[26]={0};

  FOR(i,'a','z'+1){
    int MIN = INF;
    REP(j,n){
      int cnt = 0;
      REP(k,A.at(j).size()){
        if(A.at(j).at(k)==i){
          cnt++;
        }
      }
      MIN = min(MIN,cnt);
    }
    B[i-'a']=MIN;
  }

  FOR(i,'a','z'+1){
    REP(j,B[i-'a']){
      char x = i;
      cout << x;
    }
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';


template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}

//INSERT ABOVE HERE
const Int LOG = 18;
const Int SZ = 1<<LOG;
using ll = long long;
ll dp[SZ]={};
ll binom[55][55];
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  binom[0][0]=1;
  for(Int i=0;i<52;i++){
    for(Int j=0;j<52;j++){
      binom[i+1][j+0]+=binom[i][j];
      binom[i+1][j+1]+=binom[i][j];
    }
  }

  Int n,k,s,t;
  cin>>n>>k>>s>>t;

  vector<Int> as;
  for(Int i=0;i<n;i++){
    Int a;
    cin>>a;
    if((a&s)!=s) continue;
    if((a|t)!=t) continue;
    as.emplace_back(a);
  }
  if(as.empty()) drop(0);
  n=as.size();

  ll ans=0;
  for(Int p=0;p<n;p++){
    Int b=as[p];

    memset(dp,0,sizeof(dp));
    for(Int q=p+1;q<n;q++){
      Int a=as[q];

      Int ok=0;

      for(Int j=0;j<LOG;j++){
        if(((s>>j)&1)==((t>>j)&1)) ok|=1<<j;
        if(((a>>j)&1)!=((b>>j)&1)) ok|=1<<j;
      }
      dp[ok]++;
    }

    for(Int i=1;i<SZ;i<<=1)
      for(Int j=0;j<SZ;j++)
        if((j&i)==0) dp[j|i]+=dp[j];

    for(Int bit=0;bit<SZ;bit++){
      Int ng=LOG-__builtin_popcount(bit);
      for(Int c=0;c<k;c++){
        if(ng&1) ans-=binom[dp[bit]][c];
        else ans+=binom[dp[bit]][c];
      }
    }
  }
  cout<<ans<<newl;
  return 0;
}


Measured memory_bytes: 5720
#include <bits/stdc++.h>
using namespace std;
const int PMAX = 2000000;
const int QMAX = 100000;


template <typename T>
struct node {
	T val;
	node *l, *r;
	node() {}
	node(T val) : val(val), l(nullptr), r(nullptr) {}
	void init(T v, node *left, node *right) {
		val = v;
		l = left;
		r = right;
	}
};

node<int> pool[PMAX];
node<int> *root[QMAX];

template <typename T>
class PersistentSegmentTree {
	using func_t = function<T(T, T)>;
	const int n;
	const T id;
	func_t merge;
	int it, rit;
	int size(int n) {
		int res = 1;
		while (res < n) res <<= 1;
		return res;
	}
	node<T> *new_node(int val = 0, node<T> *l = nullptr, node<T> *r = nullptr) {
		pool[it].init(val, l, r);
		return &pool[it++];
	}
	node<T> *fix(node<T> *x, int p, T val, int lb, int ub) {
		if (p < lb || ub <= p) return x;
		if (lb + 1 == ub) return new_node(val);
		int c = (lb + ub) / 2;
		auto nl = fix(x->l, p, val, lb, c);
		auto nr = fix(x->r, p, val, c, ub);
		return new_node(merge(nl->val, nr->val), nl, nr);
	}
	T sub(node<T> *x, int l, int r, int lb, int ub) {
		if (ub <= l || r <= lb) return id;
		if (l <= lb && ub <= r) return x->val;
		int c = (lb + ub) / 2;
		return merge(sub(x->l, l, r, lb, c), sub(x->r, l, r, c, ub));
	}
public:
	PersistentSegmentTree(int n_, T id_, func_t merge_) : n(size(n_)), id(id_), merge(merge_), rit(0) {
		for (int i = 1; i < n * 2; i++) {
			if (i < n) {
				pool[i - 1].init(id, &(pool[i * 2 - 1]), &(pool[i * 2]));
			}
			else {
				pool[i - 1].init(id, nullptr, nullptr);
			}
		}
		it = n * 2 - 1;
		root[rit++] = &pool[0];
	}
	node<T> *update(int p, T val, int rt = -1) {
		if (rt == -1) rt = rit - 1;
		assert(0 <= rt && rt < rit);
		return root[rit++] = fix(root[rt], p, val, 0, n);
	}
	T find(int l, int r, int rt = -1) {
		if (rt == -1) rt = rit - 1;
		assert(0 <= rt && rt < rit);
		return sub(root[rt], l, r + 1, 0, n);
	}
};

int main()
{
	cin.sync_with_stdio(false);
	int n, q, com, x, y;
	cin >> n >> q;
	PersistentSegmentTree<int> ps(n, INT_MAX, [](int l, int r) { return min(l, r); });
	while (q--) {
		cin >> com >> x >> y;
		if (com) {
			printf("%d\n", ps.find(x, y));
		}
		else {
			ps.update(x, y);
		}
	}
	return 0;
}

Measured memory_bytes: 30880
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
int main() {
    //freopen("input.txt", "r", stdin);
    unsigned long long a;
    string result = "";
    cin >> a;
    while (a > 0) {
        a--;
        result.push_back((a % 26) + 'a');
        a /= 26;
    }
    for (int i = result.size() - 1; i >= 0; i--) {
        cout << result[i];
    }
    return 0;
}

Measured memory_bytes: 3596
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>

using namespace std;

int main() {
	char S[5],sn[3];
	int A[4],si,sj,sk;
	scanf("%s", S);
	for (int i = 0; i < 4; i++) {
		A[i] = S[i] - '0';
	}
	sn[0] = '-';
	sn[1] = '+';

	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < 2; j++) {
			for (int k = 0; k < 2; k++) {
				si = 2 * i - 1;
				sj = 2 * j - 1;
				sk = 2 * k - 1;
				if (A[0] + si*A[1] + sj*A[2] + sk*A[3] == 7) {
					printf("%d%c%d%c%d%c%d=7\n", A[0], sn[i], A[1], sn[j], A[2], sn[k], A[3]);
					return 0;
				}
			}
		}
	}

}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	//例題は正解
	public static void main(String[] args) {
		//input
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt(); //N個の自然数

		int[] A = new int[N]; //N個の数列A
		for(int i=0; i<N; i++) {
			A[i] = sc.nextInt();
		}

		int Q = sc.nextInt(); //操作を行う回数

		int[][] BC = new int[2][Q]; //BとCを格納する配列
		for(int i=0; i<Q; i++) {
			BC[0][i] = sc.nextInt(); //Bを格納
			BC[1][i] = sc.nextInt(); //Cを格納
		}

		//メイン処理
		int[] list = new int[100001]; //メイン処理用配列
		long sum = 0; //合計

		//各数字が何回でてくるかカウント
		for(int i=0; i<N; i++) {
			list[A[i]]++;
		}

		//合計初期値
		for(int i=0; i<N; i++) {
			sum += A[i];
		}

		int r = 0;
		for(int i=0; i<Q; i++) {
			r = list[BC[1][i]]; //計算用に退避
			list[BC[1][i]] += list[BC[0][i]]; //Cに変えた分カウントアップ
			sum += ((long)BC[1][i]) * ((long)list[BC[1][i]] - (long)r); //増えた分sumに追加
			sum -= (long)BC[0][i] * (long)list[BC[0][i]]; //Bの部分は合計から減算
			list[BC[0][i]] = 0; //Bは数列から消える
			System.out.println(sum);
		}
	}

}


Measured memory_bytes: 60964
import sys
def strToInt(strList):
    return [int(i) for i in strList]

N, X = input().split(' ')
line = strToInt(input().split(' '))

tmp = 0
i = 1
while i-1 < int(N):
    tmp += line[i-1]
    if int(X) < tmp:
        print(i)
        sys.exit()
    i=i+1
print(i)
    

Measured memory_bytes: 3060
/**
 * File    : C.cpp
 * Author  : Kazune Takahashi
 * Created : 2018-10-6 21:04:55
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(19920725));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int N;
int x[100010];
int y[100010];
int h[100010];

void solve(int X, int Y)
{
  int ans = -1;
  for (auto i = 0; i < N; i++)
  {
    int t = h[i] + abs(x[i] - X) + abs(y[i] - Y);
    if (t <= 0)
    {
      return;
    }
    if (h[i] > 0)
    {
      if (ans != -1)
      {
        if (ans != t)
        {
          return;
        }
      }
      else
      {
        ans = t;
      }
    }
  }
  for (auto i = 0; i < N; i++)
  {
    int t = h[i] + abs(x[i] - X) + abs(y[i] - Y);
    if (h[i] == 0)
    {
      if (ans > t)
      {
        return;
      }
    }
  }
  cout << X << " " << Y << " " << ans << endl;
  exit(0);
}

int main()
{
  cin >> N;
  for (auto i = 0; i < N; i++)
  {
    cin >> x[i] >> y[i] >> h[i];
  }
  for (auto i = 0; i <= 100; i++)
  {
    for (auto j = 0; j <= 100; j++)
    {
      solve(i, j);
    }
  }
  assert(false);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	string str1;
  	cin >> str1;
  
  if(str1.at(0)==str1.at(1) && str1.at(1)==str1.at(2)){
    
      cout << "No" << endl;  
 
  }else{
    
      cout << "Yes" << endl; 
    
  }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define pii pair<int,int>
#define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
#define RREP(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define REP2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;

using namespace std;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int A,B,M;
  cin >> A >> B >> M;
  vector<int> a(A),b(B);
  REP(i,A) cin >> a[i];
  REP(i,B) cin >> b[i];
  int x[M],y[M],c[M];
  REP(i,M){
    cin >> x[i] >> y[i] >> c[i];
  }
  int ans = 9999999,tmp,s,t;
  REP(i,M){
    s = x[i] - 1; t = y[i] - 1;
    tmp = a[s] + b[t] - c[i];
    ans = min(ans,tmp);
  }
  sort(ALL(a));
  sort(ALL(b));
  ans = min(ans,a[0]+b[0]);
  cout << ans;
  return 0;
}

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

int main(){
  string S;
  cin >> S;
  string ans;
  for(int i = 0; i < S.size(); i++){
    if(S[i] != 'B'){
      ans += S[i];
    } else { 
      if(ans.size() > 0){
        ans.erase(ans.size()-1);
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
//Wining is nothing But trying To win is Everything :)
//RTn_E
#include <bits/stdc++.h>
#define __Sync ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0) ;
#define __file freopen("input.txt", "r", stdin) ; freopen("output.txt", "w", stdout) ;
typedef long long ll;

using namespace std;
ll a[100] , b[100];
int main() {
    __Sync;
    int n;
    cin >> n;
    cout << 2 * n - 1 << endl;
    int maxi = 0;
    int andi = 0;
    for (int i = 1; i <= n; i++){
        cin >> a[i];
        if (abs(a[i]) >= abs(maxi))
            maxi = a[i] , andi = i;
    }
    for (int i = 1; i <= n; i++)
        cout << andi << " " << i << endl;
    if (a[1] + a[andi] > 0){
        for (int i = 2; i <= n; i++)
            cout << i - 1 << " " << i << endl;
        return 0;
    }
    for (int i = n; i > 1; i--)
            cout << i << " " << i - 1 << endl;
        return 0;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>
#include<stack>
#include<iomanip>
#include<cstdint>
#include<bits/stdc++.h>
using namespace std;

#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPL(i,a,n) for(ll i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define SORTVG(v) sort(v.begin(),v.end(),greater<>())
#define SORTV(v) sort(v.begin(),v.end())
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> Vi;

template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}
template<class T> void YesNo(T& a) {if(a){cout << "Yes" << ENT;}else{cout << "No" << ENT;}}
template<class T> void YESNO(T& a) {if(a){cout << "YES" << ENT;}else{cout << "NO" << ENT;}}
template<class T> void AorB(T& a, string A,string B) {if(a){cout << A << ENT;}else{cout << B << ENT;}}

int atcoder(){
    vector<int> a(4),b={1,4,7,9};
    REP(i,0,4) cin>>a[i];
    SORTV(a);
    bool ans=(a==b);
    YESNO(ans);
    return 0;
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    atcoder();
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long lint;
#define rep(i,n) for(int i=0;i<n;++i)
#define MAXN 100010
#define MAXM 1100000
#define all(v) v.begin(),v.end()
#define inf 2147483647
#define linf 1152921504606846976
typedef vector<lint> LIV;

string next(int n,string s){//000=>001=>002=>003=>010(gyaku)
	++s[0];
	rep(i,n){
		if(s[i]>='4'){
			if(i==n-1)return "unko";
			++s[i+1],s[i]='0';
		}
	}
	return s;
}

int main(){

	lint n,a[3];cin>>n>>a[0]>>a[1]>>a[2];
	vector<lint> l(n);rep(i,n)cin>>l[i];
	int ans=inf;
	for(string b="00000000";"unko"!=(b=next(n,b));){
		int s[4]={},c[4]={};
		rep(i,n){
			s[b[i]-'0']+=l[i];
			c[b[i]-'0']++;
		}int tmp=0;
		if(!c[0]||!c[1]||!c[2])continue;
		rep(i,3){
			tmp+=(c[i]-1)*10+abs(a[i]-s[i]);
		}ans=min(ans,tmp);
	}cout<<ans<<endl;
}

//sub-EOF


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int apart[4][3][10] = { 0 };

	int n, b, f, r, v;

	cin >> n;

	for(int i = 0;i < n;i++) {
		cin >> b >> f >> r >> v;

		b--; f--; r--;

		apart[b][f][r] += v;
	}

	for(int i = 0;i < 4;i++) {
		for(int j = 0;j < 3;j++) {
			for(int k = 0;k < 10;k++) {
				cout << " " << apart[i][j][k];
			}

			cout << endl;
		}

		if(i < 3) {
			for(int j = 0;j < 20;j++) {
				cout << "#";
			}
		
			cout << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <math.h>

int main()
{
    double r;
    std::cin >> r;
    std::cout << std::fixed << std::setprecision(6);
    std::cout << M_PI * r * r << ' ';
    std::cout << 2 * M_PI * r;
   return 0;
}



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

int main() {
    int x; cin >> x;
    int n500 = x/500;
    int n5 = x%500/5;
    cout << n500*1000+n5*5 << endl;
}


Measured memory_bytes: 256
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define reps(i,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    vector<pair<char, int>> a;
    a.eb(s[0], 0);
    rep(i, n) {
        if (a.back().fi == s[i]) a.back().se++;
        else a.emplace_back(s[i], 1);
    }
    int l = sz(a) / 2;
    int ans = 0;
    if (l <= k) ans = n-1;
    else {
        rep(i, sz(a)) ans += a[i].se - 1;
        ans += k * 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 4500
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;


int main()
{
    int K;
    int A, B;
    cin >> K >> A >> B;

    bool ans = false;

    for (int i = A; i <= B; ++i){
        if( i%K==0){
            ans = true;
            break;
        }
    }

        if (ans)
        {
            cout << "OK" << endl;
        }
        else
        {
            cout << "NG" << endl;
        }

    return 0;
}

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

using namespace std;

#define range(i, m, n) for(int i = m; i < n; i++)
#define husk(i, m, n) for(int i = m; i > n; i--)

int n, k, s;

int main() {
  cin >> n >> k >> s;
  vector<int> a(n);
  range(i, 0, n) {
    if(i < k) a[i] = s;
    else {
      if(s < 1000000000) a[i] = s + 1;
      else a[i] = s - 1;
    }
    cout << a[i] << " ";
  }
  return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int sum=1,a,b,c,d;
	scanf("%d %d",&a,&b);
	int i=2;
	while((sum+i)-sum!=b-a)
	{
		sum+=i;
		i++;
	}
	printf("%d",sum-a);
	return 0;
}

Measured memory_bytes: 256