Language: C++

#include <cstdio>
#include <iostream>

using namespace std;

int A, B;
char op;

int main() {
	cin >> A >> op >> B;

	if (op == '+') {
		cout << A + B;
	}
	else cout << A - B;
}


#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>


using namespace std;

int A, B;
char op;
int N, M;

int main() {
	cin >> N;
	vector <int> T(N);

	for (int i = 0; i < N; i++) {
		cin >> T[i];
	}
	cin >> M;
	vector <int> P(M), X(M);
	//int P, X;

	for (int i = 0; i < M; i++) {
		cin >> P[i] >> X[i];

	}
	int res = 0;

	for (int i = 0; i < M; i++) {
		for (int j = 0; j < N; j++) {
			if (j + 1 == P[i]) {
				res += X[i];
			}
			else res += T[j];
		}

		cout << res << endl;
		res = 0;

	}

}

#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>


using namespace std;

int A, B, X;
char op;
int N, M;

int main() {
	cin >> N;
	vector <int> a(N);

	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	int i = 0, j = 0, res;

	while (1) {

		res = a[i]; //a[0]3 -> a[3-1]
		if (j > 100000) {
			cout << -1 << endl;  break;//1 a[0]3,a[2]1
		}

		i = a[i] - 1;//0 -> 
		j++;

		if (res == 2) {
			cout << j << endl;
			break;
		}

		//ループが戻ったら止める　a[0] 3 a[1]4 a[2]1 -> a[0]
	}


}


#include <cstdio > #include <vector > #include <algorithm > using namespace std; typedef long long ll; #define rep(i,n) for(int i=0;i<n;i++)
int N, M; int P[100000], Y[100000]; 
vector <int> yd[100001];
int main() {
	scanf("%d%d", &N, &M); 
	rep(i, M)scanf("%d%d", &P[i], &Y[i]), yd[P[i]].push_back(Y[i]);
	rep(i, N)sort(yd[i + 1].begin(), yd[i + 1].end());
	rep(i, M)printf("%012lld\n", ll(P[i]) * 1000000 + int(lower_bound(yd[P[i]].begin(), yd[P[i]].end(), Y[i]) - yd[P[i]].begin()) + 1); }


#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>



using namespace std;

int A, B, X;
char op;
int N, M;

vector <int> c[999999];

int main() {
	cin >> N;
	vector <int> a(N), b(N);

	for (int i = 0; i < N; i++) {
		cin >> a[i] >> b[i];
		c[a[i]].push_back(b[i]);

	}

	sort(a.begin(), a.end());

	int res, res2 = 0;
	for (int i = 0; i < N; i++) {//任意の二つのcを選ぶ cはソートされているので、
		for (int j = i; j < N; j++) {//一番遠い町をと二番目の町を足す
			res = min(abs(a[i] - c[a[i]].front()), abs(a[j] - c[a[j]].front())); //
			if (res2 > res) res2 = res;//遠い町が現れたら入れ替える。
		}
	}

	cout << res + res2 << endl;

}
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>



using namespace std;

int A, B, X;
char op;
int N, M;

//センター試験
int main() {
	cin >> N;
	string AC;

	vector <int> AAA(N);


	cin >> AC;

	for (int i = 0; i < N; i++) {
		AAA[i] = (int)(AC[i] - '0');
	}

	int res = 0, res2 = 100;

	sort(AAA.begin(), AAA.end());
	for (int i = 0; i < 4; i++) {
		res = max(res, int(count(AAA.begin(), AAA.end(), i + 1)));
		res2 = min(res2, int(count(AAA.begin(), AAA.end(), i + 1)));
	}

	cout << res << ' ' << res2 << endl;

}

#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>



using namespace std;

int A, B, X[10] = { 1,2,3,2,1,2,3,3,2,1 };
string op;
int N, M, C;

//リモコン　
int main() {
	cin >> A >> B;
	//	vector <int> AAA(N);
	int t;


	if (A < B) 	C = B - A;
	else if (A > B) C = A - B;

	t = C / 10;//28-19 =9  27 
	C = C - t * 10;//
	for (int i = 0; i < 10; i++) {
		if (C == i + 1) t += X[i];

	}
	N += t;

	if (A == B) N = 0;

	cout << N << endl;


}

#include <string>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <cmath>
#include <limits>
#include <tuple>
#include <queue>
#include <stack>

using namespace std;
typedef long long ll;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
//マップ　フィールド

bool check(const vector<string>& bd, int i, int j)
{
	rep1(k, 7) {
		static int dx[] = { 1,0,-1,0,1,1,-1,-1 };
		static int dy[] = { 0,-1,0,1,1,-1,-1,1 };
		rep(d, 8) {
			int nx = j + dx[d] * k;
			int ny = i + dy[d] * k;　//8方向の座標を出している。
			if (nx >= 0 && nx < 8 && ny >= 0 && ny < 8 && bd[ny][nx] == 'Q') {
				return true;
			}
		}
	}
	return false;
}

bool dfs(vector<string>& bd, int d)
{
	if (d == 5)
		return true;
	rep(i, 8) {
		rep(j, 8) {
			if (bd[i][j] == 'Q' || check(bd, i, j))
				continue;
			bd[i][j] = 'Q';
			if (dfs(bd, d + 1))
				return true;
			bd[i][j] = '.';
		}
	}
	return false;
}

int main()
{
	vector<string> bd(8);
	rep(i, 8) {
		cin >> bd[i];
	}
	bool noAnswer = false;
	rep(i, 8) {
		rep(j, 8) {
			if (bd[i][j] == 'Q') {
				if (check(bd, i, j)) {
					noAnswer = true;
				}
			}
		}
	}
	if (!noAnswer && dfs(bd, 0)) {
		for (auto i : bd) {
			cout << i << endl;
		}
	}
	else {
		cout << "No Answer" << endl;
	}
	return 0;
}



#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()


using namespace std;

int A, B;

int N, M, C, D;


int main() {
	cin >> N;
	vector <int> AAA(N);

	rep(i, N) cin >> AAA[i];

	int res = 0;

	rep(i, N) {
		while (AAA[i] % 2 == 0) {
			AAA[i] = AAA[i] / 2; //6-3 stop 
			res++;
		}
	}
	cout << res;



}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

long long N, M, a[100009][3], maxn = -(1LL << 60);

int main() {
	cin >> N >> M;
	for (int i = 1; i <= N; i++) {
		for (int j = 0; j < 3; j++) cin >> a[i][j];
	}
	for (int i = 0; i < 8; i++) {
		vector<long long>vec;
		for (int j = 1; j <= N; j++) {
			long long S = 0;
			for (int k = 0; k < 3; k++) { if ((i / (1 << k)) % 2 == 0) S += a[j][k]; else S -= a[j][k]; } //ここお覚えとこう。うまいやり方
			vec.push_back(S);
		}
		sort(vec.begin(), vec.end()); reverse(vec.begin(), vec.end());
		long long ans = 0;
		for (int j = 0; j < M; j++) ans += vec[j];
		maxn = max(maxn, ans);
	}
	cout << maxn << endl;
	return 0;
}


#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()

using namespace std;


int N, M, D;


int main() {
	cin >> N;
	vector <int> A(N), B(N), C(N), D(N), E(N);
	rep(i, N) cin >> A[i];
	rep(i, N) cin >> B[i];
	rep(i, N) cin >> C[i];

	sort(all(A));
	sort(all(B));
	sort(all(C));

	//各列ソートして、lowerboundして足してけばいい？
	rep(i, N) {
		D[i] = lower_bound(all(A), B[i]) - A.begin();//B[i]と組めるAが何個あるか
		E[i] = C.end() - upper_bound(all(C), B[i]);//i番目につけられるやつが何個あるか。
	}
	typedef long long res = 0;
	//２回にわけてやればいいのか。
	rep(i, N) {
		res += D[i] * E[i];
	}
	cout << res;


}




Compiler output:
a.cc:106:20: warning: extra tokens at end of #include directive
  106 | #include <cstdio > #include <vector > #include <algorithm > using namespace std; typedef long long ll; #define rep(i,n) for(int i=0;i<n;i++)
      |                    ^
a.cc:106:10: fatal error: cstdio : No such file or directory
  106 | #include <cstdio > #include <vector > #include <algorithm > using namespace std; typedef long long ll; #define rep(i,n) for(int i=0;i<n;i++)
      |          ^~~~~~~~~
compilation terminated.