akhauriyash/Code-Regression huggingface dataset:
#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, 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(const T a, const T b){return a>=0 ? a/b : (a+1)/b-1;}
template<class T> T div_ceil(const T a, const T b){return a>=0 ? (a-1)/b+1 : a/b;}

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

int N, M, r, q;
int cnt[10010][1300];

int main(){
    while(scanf("%d%d", &N, &M) && N){
        rep(i, M)rep(j, 1300) cnt[i][j] = 0;
        scanf("%d", &r);
        rep(_, r){
            int t, n, m, s;
            scanf("%d%d%d%d", &t, &n, &m, &s);
            --m;
            if(s == 1) ++cnt[m][t];
            else --cnt[m][t];
        }
        rep(i, M)rep(j, 1299) cnt[i][j+1] += cnt[i][j];
        scanf("%d", &q);
        rep(_, q){
            int s, t, m;
            scanf("%d%d%d", &s, &t, &m);
            --m;
            int ans = 0;
            For(i, s, t) ans += (cnt[m][i] > 0);
            printf("%d\n", ans);
        }
    }
}


Measured memory_bytes: 52392
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {
  ll N, A, B;
  cin >> N >> A >> B;
  if (A > B) swap(A, B);
  ll d = abs(A - B);
  
  if (d % 2 == 0) {
    cout << d / 2 << endl;
  } else {
    cout << min(A - 1, N - B) + 1 + (d - 1) / 2 << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr_inv(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define rep(i,n) repr(i,0,n)
#define INF INT_MAX
#define INFLL _I64_MAX
#define MOD 1000000007
#define PI 3.1415926535
using namespace std;
int main(void)
{
	int m;

	cin>>m;

	cout<<48-m<<endl;
}



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

using namespace std;
typedef long long ll;


int facctorialMethod(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

int main(){
    int N; cin >> N;
    vector<int> in_p,in_q;
    int p = 0;
    int q = 0;
    rep (i,N){
        int tmp;
        cin >> tmp;
        in_p.push_back(tmp);
        p += pow(10,N-1-i) * in_p[i];
    }
    //cout << p << endl;
    rep (i,N){
        int tmp;
        cin >> tmp;
        in_q.push_back(tmp);
        q += pow(10,N-1-i) * in_q[i];
    }
    //cout << q << endl;
    int k = facctorialMethod(N);
    vector<int> v(N);
    vector<int> per_list;
    iota(v.begin(), v.end(), 1);       // v に 1, 2, ... N を設定
    do {
        int tmp = 0;
            rep (i,N){
                if (i > 0){
                    tmp += pow(10,i) * v[i];
                }
                else {
                    tmp += v[i];
                }
            }
        per_list.push_back(tmp);
    } while( next_permutation(v.begin(), v.end()) );
    sort(per_list.begin(),per_list.end());
    int p_count = 0;
    int q_count = 0;

    for (const auto v:per_list){
        if (p > v){
            p_count++;
        }
        if (q > v){
            q_count++;
        }
        //cout << v << endl;
    }
    //cout << p_count << endl;
    //cout << q_count << endl;
    int tmp = abs(q_count-p_count);
    cout << tmp << endl;
    return 0;
}

Measured memory_bytes: 4200
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int mod = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1.0);

int main()
{
    int n;
    cin >> n;
    int sum = 0,tmp = n;
    while(tmp){
        sum += tmp%10;
        tmp /= 10;
    }
    cout << (n%sum ? "No" : "Yes") << endl;
    return 0;
}


Measured memory_bytes: 256
//https://atcoder.jp/contests/abc100/tasks/abc100_d
//D - Patisserie ABC
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
const ll LINF = 0x1fffffffffffffff;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
template<class T>bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1; } return 0;}
template<class T>bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1; } return 0;}
int main() {
  ll N,M; cin>>N>>M;
  struct info{
    array<ll,3> xyz;
    ll id;
  };
  vector<info> infon(N);
  REP(n,N){
    auto&& i=infon.at(n);
    cin>>i.xyz[0]>>i.xyz[1]>>i.xyz[2];
    i.id=n;
  }

  ll ans=0;
  ll bit_max=1<<3;
  FOR(m,0,bit_max){
    using pa=pair<ll,ll>; //value,id
    vector<pa> lst(N);
    REP(i,N){
      const auto& info=infon.at(i);
      auto&& l=lst.at(i);
      FOR(i,0,3){
        ll sig=m&(1<<i)?-1:1;
        l.first += (info.xyz[i]*sig);
      }
      l.second=i;
    }
    sort(lst.begin(),lst.end());
    reverse(lst.begin(),lst.end());
    //value
    ll x=0,y=0,z=0;
    REP(i,M){
      auto id= lst.at(i).second;
      const auto & info=infon.at(id);
      x+=info.xyz[0];
      y+=info.xyz[1];
      z+=info.xyz[2];
    }
    chmax(ans,abs(x)+abs(y)+abs(z));
  }
  cout<<ans<<endl;

  return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

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

const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const bool debug = 0;

int N;
int p[100];

int main() {
	cin >> N;
	REP(i, N) scanf("%d", p + i);
	
	int ans = -1;
	REP(i, 101) {
		int cnt = 0;
		REP(j, N) if (p[j] >= i) cnt++;
		if (cnt >= i) ans = i;
	}
	cout << ans << endl;
	
	return 0;
}

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

int main(){
  int A=0,B=0,X,n=1;
  cin >> X;
  for(A = 0;;A++){
    bool finish = false;
    for(B=0;B<n*5;B++){
      if(A*A*A*A*A-B*B*B*B*B == X){
        cout << A << " "<< B <<endl; 
        finish = true;
        break;
      }
      else if(A*A*A*A*A+B*B*B*B*B == X){
        cout << A << " "<< -1*B <<endl; 
        finish = true;
        break;
      }
      else if(-A*A*A*A*A-B*B*B*B*B == X){
        cout << -1*A << " "<< B <<endl; 
        finish = true;
        break;
      }
      else if(-A*A*A*A*A+B*B*B*B*B == X){
        cout << -1*A << " "<< -1*B <<endl; 
        finish = true;
        break;
      }
    }
    if(A*A*A*A*A-B*B*B*B*B == X){
      break;
    }
    else if(A*A*A*A*A+B*B*B*B*B == X){
      break;
    }
    else if(-A*A*A*A*A-B*B*B*B*B == X){
      break;
    }
    else if(-A*A*A*A*A+B*B*B*B*B == X){
      break;
    }
    n++;
  }
}

Measured memory_bytes: 3640
#include<iostream>
#include<algorithm>

const int MAX_N = 100, MAX_M = 100, INF = 1 << 24;
int n, m;
int cost[MAX_N][MAX_N], mincost[MAX_N], used[MAX_N];

int prim(){
	std::fill(mincost, mincost+MAX_N, INF);
	std::fill(used, used+MAX_N, 0);

	mincost[0] = 0;
	int res = 0;
	while(true){
		int v = -1;
		for(int i=0;i<n;i++){
			if(!used[i] && (v == -1 || mincost[i] < mincost[v])){
				v = i;
			}
		}

		if(v == -1){
			break;
		}
		used[v] = 1;
		res += mincost[v];

		for(int i=0;i<n;i++){
			mincost[i] = std::min(mincost[i], cost[v][i]);
		}
	}

	return res;
}

int main(){
	while(std::cin >> n >> m, n){
		for(int i=0;i<MAX_N;i++){
			std::fill(cost[i], cost[i]+MAX_N, INF);
		}
		for(int i=0;i<m;i++){
			int a, b, c;
			std::cin >> a >> b >> c;
			cost[a][b] = c;
			cost[b][a] = c;
		}
		std::cout << prim() << std::endl;
	}
}

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

int gcd(int a, int b) {
    while (b != 0) {
        auto t = b;
        b = a % b;
        a = t;
    }
    return a;
}

int main() {
    int n, k, g = 0, m = 0;
    cin >> n >> k;
    for (int a; cin >> a; g = gcd(g, a), m = max(m, a)) {
    }
    if (k % g == 0 && k <= m) {
        cout << "POSSIBLE";
    } else {
        cout << "IMPOSSIBLE";
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){


	int n, x, c;
	int i, j, k;	


	while(1){
		scanf( "%d %d", &n, &x );

		if( n==0 && x==0 ) break;

		c = 0;
		for( i=1; i<=n; i++ ){
		for( j=i+1; j<=n; j++ ){
		for( k=j+1; k<=n; k++){
	
			if( i+j+k == x ) c++;

		}}}


		printf( "%d\n", c );
	}



	return 0;

}

Measured memory_bytes: 600
if __name__ == "__main__":
    N,K = map(int,input().split())
    ans = 0
    for i in range(K,N+2):
        a = i*(2*N-i+1)/2
        b = i*(i-1)/2
        ans = (ans + a - b+1) % (10**9+7)
    print(int(ans))

Measured memory_bytes: 9192
#include <iostream>
#include <vector>
#include <map>

using namespace std;

int main()
{
	int N, T;
	long long ans = 0;
	cin >> N >> T;

	vector<int> t(N);
	vector<pair<int, int>> times;
	for (int i = 0; i < N; i++)
		cin >> t[i];

	pair<int, int> p;
	p.first = t[0];
	p.second = t[0] + T;
	times.push_back(p);

	int j = 0;
	for (int i = 1; i < N; i++)
	{
		if (times[j].second >= t[i])
			times[j].second = t[i] + T;
		else
		{
			p.first = t[i];
			p.second = t[i] + T;
			times.push_back(p);
			j++;
		}
	}

	for (int i = 0; i < times.size(); i++)
		ans += times[i].second - times[i].first;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int x[3000];
int y[3000];

bool z[5001][5001];

int main()
{
	while(1)
	{
		int n;
		scanf("%d",&n);
		if(n == 0)
		{
			break;
		}
		for(int i = 0; i < 5001; i++)
		{
			for(int ii = 0; ii < 5001; ii++)
			{
				z[i][ii] = false;
			}
		}
		for(int i = 0; i < n; i++)
		{
			int xw,yw;
			scanf("%d %d",&xw,&yw);
			x[i] = xw;
			y[i] = yw;
			z[yw][xw] = true;
		}
		int max = 0;
		for(int i = 0; i < n; i++)
		{
			for(int ii = 0; ii < n; ii++)
			{
				int xz = x[ii] - x[i];
				int yz = y[ii] - y[i];
				int x1 = x[i] + yz;
				int y1 = y[i] - xz;
				int x2 = x[ii] + yz;
				int y2 = y[ii] - xz;
				if(x1 >= 0 && x1 <= 5000 && y1 >= 0 && y1 <= 5000 && x2 >= 0 && x2 <= 5000 && y2 >= 0 && y2 <= 5000)
				{
					if(z[y1][x1] && z[y2][x2])
					{
						if(max < xz * xz + yz * yz)
						{
							max = xz * xz + yz * yz;
						}
					}
				}
			}
		}
		printf("%d\n",max);
	}
	return 0;
}

Measured memory_bytes: 25472
#include<stdio.h>
#include<math.h>
struct _data{
	long double d[4];
}typedef data;
#define N 24
long double triangle(long double d1[],long double d2[], long double d3[]){
	long double h1,h2,h3,s,S;
	h1=(long double)sqrt((double)((d3[1]-d2[1])*(d3[1]-d2[1])+(d3[0]-d2[0])*(d3[0]-d2[0])));
	h2=(long double)sqrt((double)((d3[1]-d1[1])*(d3[1]-d1[1])+(d3[0]-d1[0])*(d3[0]-d1[0])));
	h3=(long double)sqrt((double)((d1[1]-d2[1])*(d1[1]-d2[1])+(d1[0]-d2[0])*(d1[0]-d2[0])));
	s=(h1+h2+h3)/2.0;
	S=(long double)sqrt((double)(s*(s-h1)*(s-h2)*(s-h3)));
	return S;
}
int main(){
	data s[30];
	long double S=0;
	int i;
	for(i=0;scanf("%Lf,%Lf",&s[i].d[0],&s[i].d[1])!=EOF;i++){
		if(i>1){
			S+=triangle(s[0].d,s[i-1].d,s[i].d);
		}
	}
	printf("%Lf\n",S);
	return 0;
}

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

int a[100000];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int ai;
    cin >> ai;
    a[ai]++;
  }
  int ans = 0;
  for (int i = 1; i <= 100000; ++i) {
    if (a[i] > 0) {
      ++ans;
    }
  }
  if (ans % 2 == 0) {
    --ans;
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
# Author: cr4zjh0bp
# Created: Sat Mar 14 13:11:12 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

from math import ceil

h, w = na()

if h == 1 or w == 1:
    print(1)
else:
    print(ceil(h * w / 2))

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<set>
#define LL long long
LL N, X, ans;
void solve(LL a, LL b) {
	ans += (b * 3)*(a / b);
	if (a%b)solve(b, a%b);
}
int main() {
	std::cin >> N >> X;
	solve(std::max(X, N - X), std::min(X, N - X));
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n;
char ans[1010][1010];
void print()
{
	for(int i=1;i<=n;++i)
	{
		for(int j=1;j<=n;++j)
			if(ans[i][j])putchar(ans[i][j]);
			else putchar('.');
		printf("\n");
	}
}
int main()
{
	scanf("%d",&n);
	if(n==1||n==2)return printf("-1"),0;
	if(n%3==0)
	{
		for(int i=1;i<=n/3;++i)
		{
			ans[i*3-2][i*3-2]=ans[i*3-1][i*3-2]='a';
			ans[i*3][i*3-1]=ans[i*3][i*3]='b';
		}
		print();
		return 0;
	}
	if(n==7)
	{
		printf("\
a.bb.cc\n\
ad.ee..\n\
.df.gg.\n\
h.f..ii\n\
hj....k\n\
.jl...k\n\
mmlnn..\n\
		");
		return 0;
	}
	if(n==11)
	{
		printf("\
abbcc......\n\
add.e......\n\
f..ge......\n\
f..gh......\n\
iijjh......\n\
.....aa.ccd\n\
.......bf.d\n\
.......bfee\n\
.....ccdaa.\n\
.....f.d..b\n\
.....fee..b\n\
		");
		return 0;
	}
	int p;
	for(int i=0;;++i)
		if((n-i*4)%5==0)
		{
			p=i;break;
		}
	for(int i=1;i<=p;++i)
	{
		ans[i*4-3][i*4-3]=ans[i*4-2][i*4-3]='a';
		ans[i*4-3][i*4-2]=ans[i*4-2][i*4-2]='b';
		ans[i*4-3][i*4-1]=ans[i*4-3][i*4]='c';
		ans[i*4-2][i*4-1]=ans[i*4-2][i*4]='d';
		ans[i*4-1][i*4-3]=ans[i*4-1][i*4-2]='e';
		ans[i*4][i*4-3]=ans[i*4][i*4-2]='f';
		ans[i*4-1][i*4-1]=ans[i*4][i*4-1]='g';
		ans[i*4-1][i*4]=ans[i*4][i*4]='h';
	}
	for(int i=1,s=p*4;i<=(n-p*4)/5;++i,s+=5)
	{
		ans[s+1][s+1]=ans[s+2][s+1]='a';
		ans[s+3][s+1]=ans[s+4][s+1]='b';
		ans[s+5][s+1]=ans[s+5][s+2]='c';
		ans[s+5][s+3]=ans[s+5][s+4]='d';
		ans[s+1][s+2]=ans[s+1][s+3]='e';
		ans[s+1][s+4]=ans[s+1][s+5]='f';
		ans[s+2][s+5]=ans[s+3][s+5]='g';
		ans[s+4][s+5]=ans[s+5][s+5]='h';
		ans[s+2][s+2]=ans[s+2][s+3]='i';
		ans[s+3][s+4]=ans[s+4][s+4]='j';
	}
	print();
	return 0;
}


Measured memory_bytes: 2176
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <numeric>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <thread>
#include <tuple>
#include <limits>

using namespace std;

int dp[100002];
int main() {
  dp[0] = 1;
  for (int price : {100, 101, 102, 103, 104, 105}) {
    for (int i = 0; i + price <= 100000; i++) {
      if (dp[i] == 0) continue;
      dp[i + price] = 1;
    }
  }
  int X;
  scanf("%d", &X);
  printf("%d\n", dp[X]);
  return 0;
}


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

typedef long long ll;
const int INF = 1e9;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n; cin>>n;
	string v[4] = {"AC", "WA", "TLE", "RE"};
	int ans[4] = {0};
	for (int i = 0; i < n; i++){
		string s; cin>>s;
		for (int j = 0; j < 4; j++){
			if (s == v[j]){
				ans[j]++;
			}
		}
	}
	for (int i = 0; i < 4; i++){
		cout<<v[i]<<" x "<<ans[i]<<'\n';
	}
	return 0;
}

Measured memory_bytes: 3652
#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>;
 
int main(){
	int n;
	cin >> n;
    int a = 0;
    for(int i=1; i<=n; i++){
      int b = i;
      int k = 0;
      while(b > 0){
        b/=10;
        k++;
      }
      if(k%2 == 1) a++;
    }
	cout << a << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<bitset>
#include<string>
#include<vector>

using namespace std;

string s;
int x, y;
vector<int> moving[2];
const int geta = 8000 + 10;
bitset<geta * 2> dp[4000 + 10];

int main() {
	cin >> s >> x >> y;
	int length = 0;
	bool f = false;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'F')length++;
		else {
			moving[f].push_back(length);
			length = 0;
			f = !f;
		}
	}
	if (length != 0)moving[f].push_back(length);
	length = 0, f = !f;

	dp[0][geta + 0] = true;
	for (int i = 0; i < moving[0].size(); i++) {
		if(!(s[0] == 'F' && i == 0))dp[i + 1] |= (dp[i] >> moving[0][i]);

		dp[i + 1] |= (dp[i] << moving[0][i]);
	}
	if (!dp[moving[0].size()][geta + x]) {
		cout << "No" << endl;
		return 0;
	}

	for (int i = 0; i <= 4000; i++) {
		dp[i] = 0;
	}
	dp[0][geta + 0] = true;
	for (int i = 0; i < moving[1].size(); i++) {
		dp[i + 1] |= (dp[i] << moving[1][i]);
		dp[i + 1] |= (dp[i] >> moving[1][i]);
	}
	if (!dp[moving[1].size()][geta + y]) {
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 8192
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 100005

int N;
map<int,int> MAP;

int main(){

	int table[NUM],count[NUM];

	scanf("%d",&N);

	for(int i = 0; i < N; i++){

		count[i] = 0;
	}

	int tmp;
	vector<int> V;

	for(int i = 0; i < N; i++){

		scanf("%d",&tmp);
		table[i] = tmp;
		V.push_back(tmp);
	}

	sort(V.begin(),V.end());
	V.erase(unique(V.begin(),V.end()),V.end());

	for(int i = 0; i < V.size(); i++){

		MAP[V[i]] = i;
	}

	for(int i = 0; i < N; i++){

		count[MAP[table[i]]]++; //辺の本数を数える
	}

	ll max_1 = 0,max_2 = 0,max_seihou = 0;

	for(int i = 0; i < V.size(); i++){

		if(count[i] >= 4){

			max_seihou = V[i];
		}

		if(count[i] >= 2){
			max_2 = max_1;
			max_1 = V[i];
		}
	}

	printf("%lld\n",max(0LL,max(max_seihou*max_seihou,max_1*max_2)));

	return 0;
}


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

int main(void) {
    string s;

    cin >> s;
    int first_c = 0, second_c = 0;
    first_c = s[0];
    int f_count = 1, s_count=1;
    for (int i=1; i<4; i++) {
        if (first_c != s[i]) {
            if (second_c == 0) {
                second_c = s[i];
            } else if (second_c != s[i]) {
                cout << "No";
                return 0;
            } else {
                s_count++;
            }
        } else {
            f_count++;
        }
    }
    if (f_count == 2 && s_count == 2) cout << "Yes";
    else cout << "No";

    return 0;
}


Measured memory_bytes: 256
/*
  AUTHOR:SOURABH
  CREATED:22:03:20
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ordered_set tree<pll , null_type, less< pll >, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define W while
#define fn(i,x) for(i=0;i<x;i++)
#define fs(i,s,x) for(i=s;i<x;i++)
#define fr(i,x) for(i=x;i>=0;i--)
#define fit(it,s) for(it=s.begin();it!=s.end();it++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define mod 1000000007
#define MAX 100005
#define M 32

using namespace std;
using namespace __gnu_pbds;

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

    //freopen("in.txt","r",stdin);
    //freopen(2 "out.txt","w",stdout);

    ll t,n,m,ans;
    t=1;
    //cin>>t;
    W(t--)
    {
        cin>>n>>m;
        ans=(n*(n-1))/2+(m*(m-1))/2;
        cout<<ans;

    }
    return 0;
}








































Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
// 9 3
// 0001000100
int main(){
    int n, step_len;
    cin >> n >> step_len;
    string sugoroku;
    cin >> sugoroku;
    stack<int> ans;
    int last_len = 0;
    int len_max = 0;
    for (int i = n-1; i > -1; --i){
        len_max++;
        if (len_max > step_len){
            if (last_len == 0){
                cout << -1 << endl;
                return 0;
            } else {
                ans.push(last_len);
                len_max -= last_len;
                last_len = 0;
            }
        }
        if (sugoroku[i] == '0'){
            last_len = len_max;
        }
        if (i == 0){
            ans.push(last_len);
        }
    }
    while (!ans.empty()) {
        printf("%d ", ans.top());
        ans.pop();
    }
    return 0;
}

Measured memory_bytes: 868
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int sx,sy,tx,ty;
    scanf("%d%d%d%d",&sx,&sy,&tx,&ty);
    printf("L");//左から出る
    for(int i=0;i<ty-sy+1;i++){
        printf("U");
    }
    for(int i=0;i<tx-sx+1;i++){
        printf("R");
    }
    printf("D");//上から入る
    for(int i=0;i<tx-sx;i++){
        printf("L");
    }//左から出る
    for(int i=0;i<ty-sy;i++){
        printf("D");
    }//上から入る
    printf("D");//下から出る
    for(int i=0;i<tx-sx+1;i++){
        printf("R");
    }
    for(int i=0;i<ty-sy+1;i++){
        printf("U");
    }
    printf("L");//右から入る
    for(int i=0;i<ty-sy;i++){
        printf("D");
    }//下から出る
    for(int i=0;i<tx-sx;i++){
        printf("L");
    }//右から入る
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <cstdio>
#include <cstring>
#include <cmath>

using namespace std;

typedef unsigned long long ull;
typedef signed long long sll;

int main()
{
    sll x;
    
    cin >> x;
    
    ull ans = (x / 11) * 2;
    ull mod = x % 11;
    if (mod > 6)
    {
        ans += 2;
    }
    else if (0 < mod && mod <= 6)
    {
        ans += 1;
    }
    
    printf("%lld\n", ans);
    
    return 0;
}


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

using namespace std;

int main()
{
    string o, e;
    cin >> o >> e;

    int i;
    for (i = 0; i < e.size(); ++i) {
        cout << o[i];
        cout << e[i];
    }
    if (i < o.size()) {
        cout << o[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
N,A,B,C = list(map(int,input().split()))
l = []
for i in range(N):
    l.append(int(input()))

choiceList = []
for i in range(4 ** N):
    choice = [-1 for i in range(N)]
    for j in range (N):
        choice[j] = i // (4 ** j) % 4
    choiceList.append(choice)

minCost = 10 ** 9
for choice in choiceList:
    cost = 10 ** 9
    aList = []
    bList = []
    cList = []
    for i in range(N):
        if choice[i] == 1:
            aList.append(l[i])
        elif choice[i] == 2:
            bList.append(l[i])
        elif choice[i] == 3:
            cList.append(l[i])
    if len(aList) == 0 or len(bList) == 0 or len(cList) == 0:
        cost = 10 ** 9
    else:
        aCost = (len(aList) - 1) * 10 + abs(sum(aList) - A)
        bCost = (len(bList) - 1) * 10 + abs(sum(bList) - B)
        cCost = (len(cList) - 1) * 10 + abs(sum(cList) - C)
        cost = aCost + bCost + cCost
    if minCost > cost:
        minCost = cost

print(minCost)

Measured memory_bytes: 17884
X,Y,A,B,C=map(int,input().split())

RO=list(map(int,input().split()))
GO=list(map(int,input().split()))
TO=list(map(int,input().split()))

RO.sort()
GO.sort()

R=RO[A-X:A]
G=GO[B-Y:B]

TO.extend(R)
TO.extend(G)

TO.sort(reverse=True)

T=TO[0:X+Y]

print(sum(T))

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

int main(){
	string s1,s2;
	cin>>s1>>s2;
	int ans=0;
	for(int i=0;i<3;++i){
		if(s1[i]==s2[i])ans++;
	}
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const int mod = 1000000007;

int main() {
  int n;
  cin >> n;
  vector<ll> a(n), b(n);
  vector<ll> score(n);
  ll ans = 0;
  rep(i, n) {
    cin >> a[i] >> b[i];
    score[i] = a[i] + b[i];
    ans += a[i];
  }
  sort(score.rbegin(), score.rend());

  rep(i, n) {
    if (i % 2) ans -= score[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int gcd(int a, int b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

const ll INF = 1LL << 60;

int main(){
  int n,m; cin >> n >> m;
  vvi G(n);
  vi deg(n);
  rep(i, m){
    int a,b; cin >> a >> b;
    a--; b--;
    G[a].pb(b); G[b].pb(a);
    deg[a]++; deg[b]++;
  }

  queue<int> q;
  rep(i, n) if(deg[i]==1) q.push(i);
  vector<bool> pushed(n,false);

  while (!q.empty()) {
    int v = q.front(); q.pop();
    pushed[v] = true;
    for(auto nv : G[v]){
      deg[nv]--;
      if(deg[nv] == 1) q.push(nv);
    }
  }

  int cnt = 0;
  rep(i, n) if(pushed[i]) cnt++;
  if(cnt==n) cnt--;
  std::cout << cnt << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include<climits>
using namespace std;
int main(void){
    int n,x,m,a=INT_MAX;
    cin>>n>>x;
    int count = n;
    for(int i=0; i<n; i++){
        cin>>m;
        a=min(a,m);
        x-=m;
    }
       count +=x/a;
       cout<<count<<endl;
        }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// types
typedef long long ll; 
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
// IO
#define fo(i, n) for (int i = 0; i < n; i++)
#define fo1(i, n) for (int i = 1; i <= n; i++)
#define sc(n) scanf("%d", &n) 
#define sca(a, n) fo(i, n) sc(a[i])
#define pd(a) printf("%d ", a)
#define pld(a) printf("%d\n", a)
#define pda(a, n) fo(i, n) pd(a[i])
#define pl printf("\n")
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b) 
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
// math
const ll mod = 1e9+7;
template<typename T> T gcf(T a, T b) {return (b == 0) ? a : gcf(b, a%b);} 
template<typename T> T lcm(T a, T b) {return (a*b)/gcf(a, b);}
template<typename T> T sumTo(T x) {return x * (x+1) / 2;}
template<typename T> T sumSquaresTo(T x) {return x * (x+1) * (2*x+1) / 6;}
template<typename T> T ceilDiv(T n, T d) {return (n+d-1)/d;}
    
const int MAXN = 15;
int n, m, a[MAXN];
bool decided[MAXN];
    
void solve() {
    sc(n); sc(m);
    fo1(i, n) {
        a[i] = 0;
        decided[i] = false;
    }
    int s, c;
    fo(i, m) {
        cin >> s >> c;
        if (decided[s] && a[s] != c) {
            pd(-1);
            return;
        }
        decided[s] = true;
        a[s] = c;
    }
    if (n > 1 && !a[1]) {
        if (decided[1]) {
            pd(-1);
            return;
        }
        a[1] = 1;
    } 
    fo1(i, n) cout << a[i];
}
    
int main() {
    int t = 1;
    //scanf("%d", &t);
    while (t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
from math import factorial

# input
N, M = map(int, input().split())

if N <= 1 and M <= 1:
    print(0)
elif M <= 1:
    print(int(factorial(N) / factorial(2) / factorial(N - 2)))
elif N <= 1:
    print(int(factorial(M) / factorial(2) / factorial(M - 2)))
else:
    print(int(
            (factorial(N) / factorial(2) / factorial(N - 2))
            + (factorial(M) / factorial(2) / factorial(M - 2))
        )
    )


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <math.h>
using namespace std;

int main() {
    int x, y;
    cin >> x >> y;

    int p[13] = {};
    p[4] = p[6] = p[9] = p[11] = 1;
    p[2] = 2;

    cout << (p[x] == p[y] ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 09/08/20 03:55:25
// -----------------------------------

#include <bits/stdc++.h>
#include <atcoder/dsu.hpp>

using namespace std;
using ll = long long;

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

  int n,q; cin>>n>>q;
  atcoder::dsu dsu(n);
  while (q--) {
    int t,u,v; cin>>t>>u>>v;
    if (t == 0) {
      dsu.merge(u, v);
    } else {
      cout << dsu.same(u, v) << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 3828
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int csum[100005];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n, k;
    string s;
    cin >> n >> k >> s;
    
    vector<int> sum;
    int now = 1;
    int id = 0;
    int cnt = 0;
    while(id < n){
        if(s[id] - '0' == now){
            ++cnt;
        }
        else{
            sum.push_back(cnt);
            now ^= 1;
            cnt = 1;
        }
        ++id;
    }
    sum.push_back(cnt);
    
    if(sum.size() % 2 == 0)     sum.push_back(0);
    
    // 累積和
    for(int i = 0; i < sum.size(); ++i){
        csum[i+1] = csum[i] + sum[i];
    }
    
    int ans = 0;
    int add = 2 * k + 1;
    for(int i = 0; i < sum.size(); i += 2){
        int left = i;
        int right = min(i + add, (int)sum.size());
        
        int temp = csum[right] - csum[left];
        
        ans = max(ans, temp);
    }
    
    
    cout << ans << endl;
}

Measured memory_bytes: 1272
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
using namespace std;
int main() {
  int n,a[20]={},b[20]={},c[19]={},ans=0;
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> a[i];
  }
  for(int i=0; i<n; i++) {
    cin >> b[i];
  }
  for(int i=0; i<n-1; i++) {
    cin >> c[i];
  }
  for(int i=0; i<n; i++) {
    if(a[i]+1==a[i+1]) {
      ans+=c[a[i]-1];
    }
  }
  for(int i=0; i<n; i++) {
    ans+=b[a[i]-1];
  }
  cout << ans << endl;
}

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

#define MAX 200000
#define SENTINEL 2000000000
typedef long long llong;

int L[MAX / 2 + 2], R[MAX / 2 + 2];

llong merge(int A[], int n, int left, int mid, int right){
    int i, j, k;
    llong cnt = 0;
    int n1 = mid - left;
    int n2 = right - mid;
    for(i=0; i<n1; i++) L[i] = A[left + i];
    for(i=0; i<n2; i++) R[i] = A[mid + i];
    L[n1] = R[n2] = SENTINEL;
    i = j = 0;
    for(k=left; k<right; k++){
        if(L[i] <= R[j]){
            A[k] = L[i++];
        }else{
            A[k] = R[j++];
            cnt += n1 -i; // = mid + j - k -1
        }
    }
    return cnt;
}

llong mergeSort(int A[], int n, int left, int right){
    int mid;
    llong v1, v2, v3;
    if(left + 1 < right){
        mid = (left + right) / 2;
        v1 = mergeSort(A, n, left, mid);
        v2 = mergeSort(A, n, mid, right);
        v3 = merge(A, n, left, mid, right);
        return v1 + v2 + v3;
    }else return 0;
}

int main(){
    int A[MAX], n, i;

    cin >> n;
    for(i=0; i<n; i++){
        cin >> A[i];
    }

    llong ans = mergeSort(A, n, 0, n);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4676
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
#include<stdio.h>
#include<cmath>
#include<limits>
#include<iomanip>

using namespace std;

const long long INF = 1LL << 60;

//各桁の和を出力
long long Sum(long long n) {
long long m=0;
  while(n){
    m+=n%10;
    n/=10;
  }
  return m;
}

const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}


#define comuse Comuse()
//nCk(comuseを使え)
long long combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
//pCk(comuseを使え)
long long perm(int n,int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] % MOD) % MOD;
}

//最小公倍数(aとbの)
long long lcm(long long a,long long b){
  long long n;
  n=a/__gcd(a,b)*b;
  return n;
}

//auto A = div(n)
vector<long long> div(long long n){
  vector<long long> ret;
  for(long long i=1;i*i<=n;i++){
    if(n%i==0){
      ret.push_back(i);
      if(i*i!=n){
        ret.push_back(n/i);
      }
    }
  }
  sort(ret.begin(),ret.end());
  return ret;
}

//(aのn乗をmodで割ったあまり)
long long modpow(long long a,long long n,long long mod){
  long long ans=1;
  while(n>0){
    if(n&1){
      ans=ans*a%mod;
    }

    a=a*a%mod;
    
    n>>=1;
  }

  return ans;
}

void Solve();


const int MAX_N = 131072;
//segment tree 
int NN;
int seg[MAX_N*2-1];
void seguse(){
  for(int i=0;i<2*NN-1;i++){
    seg[i]=INT_MAX;
  }
}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(20)<<fixed;
  Solve();
}

///////////////////////////////////////////////////////////

string S;

void Solve(){
  int count = 0;
  cin >> S;
  for(int i = 0; i < S.size()/2; i++){
    if(S[i] != S[S.size()-1-i]){
      count ++;
    }
  }
  cout << count <<endl;
}

Measured memory_bytes: 256
#include <iostream>


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

    int next = (A / K + 1) * K;
    if (A % K == 0 ) {
        std::cout << "OK" << std::endl;
    } else if (A <= next &&  next <= B) {
        std::cout << "OK" << std::endl;
    } else {
        std::cout << "NG" << std::endl;
    }
}


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

const int N=3010;
double T[N],L;
int n;
double Pi=acos(-1.0)*2;

int main(){
	scanf("%d %lf",&n,&L);
	for(int i=1;i<=n;i++) scanf("%lf",&T[i]),T[i]/=L;
	double xx=0,yy=0,nowT;
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++){
			if(T[j]-T[i]>0.5) {
				nowT=(T[i]+T[j]+1)/2;
				xx+=cos(nowT*Pi)*(j-i-1),yy+=sin(nowT*Pi)*(j-i-1);
				nowT+=1.0/2;
				xx+=cos(nowT*Pi)*(n-j+i-1),yy+=sin(nowT*Pi)*(n-j+i-1);
			}
			else{
				nowT=(T[i]+T[j])/2;
				xx+=cos(nowT*Pi)*(n-j+i-1),yy+=sin(nowT*Pi)*(n-j+i-1);
				nowT+=1.0/2;
				xx+=cos(nowT*Pi)*(j-i-1),yy+=sin(nowT*Pi)*(j-i-1);
			}
		}
	xx*=6.0/n/(n-1)/(n-2);yy*=6.0/n/(n-1)/(n-2);
	printf("%.15lf %.15lf",xx,yy);
} 

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
long memo[100]={0};
long ryuka(long n){
	if(n==0) return 2;
  	else if(n==1) return 1;
  	else if(memo[n]!=0) return memo[n]; 
    else return memo[n]=ryuka(n-1) + ryuka(n-2);
}

int main(){
  
  long N;
  cin >> N;
  
  cout << ryuka(N) << endl;
  
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;

public class Main {

    private static final int COUNT = 5;

    public static void main(String[] args) throws Exception {
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
            int[] waitTime = new int[COUNT];
            for (int i = 0; i < COUNT; ++i) {
                waitTime[i] = Integer.parseInt(reader.readLine());
            }
            eval(waitTime);
        }
    }

    public static void eval(int[] waitTime) {
        int[] r = Arrays.stream(waitTime)
                .boxed()
                .sorted(Comparator.comparing(i -> cost(i)))
                .mapToInt(Integer::intValue)
                .toArray();
        int u = Arrays.stream(r, 0, r.length - 1).map(i -> upToMulOf10(i)).sum();
        int res = u + r[r.length - 1];
        System.out.println(res);
    }

    public static int cost(int num) {
        return upToMulOf10(num) - num;
    }

    public static int upToMulOf10(int num) {
        int d = (num % 10);
        return d == 0 ? num : num + (10 - d);
    }

}


Measured memory_bytes: 29524
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;
#define FIX cout << fixed << setprecision(15)

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define VVi vector<vector<ll>>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

template<class T> inline bool chmin(T& a, T b) {if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if(a<b){a=b;return true;}return false;}

using ll = long long;
using Graph = vector<vector<int>>;

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll a,ll b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

ll lcm2(ll a, ll b) {
  ll g = gcd(a,b);
  return a / g * b;
}

signed main() {
  RAPID;
  // デフォルト変数定義
  ll n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN(n);
  ll ans = 1LL;
  REP(i,n){
    IN(x);
    ans = lcm2(ans, x);
  }
  OUT(ans);
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int a, b;
int keta(int b)
{
  int keta2 = 0;
  while(b>0)
  {
    b /= 10;
    keta2++;
  }
  return keta2;
}
int main()
{
  cin>>a>>b;
  for(int i=0;i<keta(b);i++)
    a *= 10;
  int c = a + b;
  for (int i = 4; i <= 1000;i++)
  {    
    if(c==i*i)
    {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}  

Measured memory_bytes: 256
/*
 * Finding_a_Word.cpp
 *
 *  Created on: 2014/08/03
 *      Author: WanWan1985
 */
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
using namespace std;

// for util
#define FOR(i, a, b) 	for(int i = (a); i < (b); i++)
#define REP(i, n)		FOR(i, 0, n)
#define PB				push_back
#define MP				make_pair
#define CL				clear
#define EXIT			(0)

typedef unsigned int u_int;
typedef long long ll;

int strcmp(string lhs, string rhs);

int main(void) {

	string strTargetWord;
	cin >> strTargetWord;

	int iCounter = 0;
	string strWord;
	while (cin >> strWord) {

		string::size_type pos = strWord.find("END_OF_TEXT", 0);
		if (pos != string::npos) {
			break;
		}

		if (!strcmp(strWord, strTargetWord)) {
			iCounter++;
		}
	}
	cout << iCounter << endl;

	return EXIT;
}

int strcmp(string lhs, string rhs) {
	transform(lhs.begin(), lhs.end(), lhs.begin(), ::toupper);
	transform(rhs.begin(), rhs.end(), rhs.begin(), ::toupper);
	return lhs.compare(rhs);
}

Measured memory_bytes: 1192
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        int max = Math.min(a, b);
        int min = Math.max(0, a + b - n);
        String result = max + " " + min;

        // 出力
        System.out.println(result);
    }
}


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

using namespace std;

typedef long long ll;

ll maxINT = 1000000000000000000;

int main (){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll N;
    cin >> N;
    vector<pair<ll,ll>> v(N+1);
    for(int i = 1 ; i < N+1; ++i){
        ll a;
        cin >> a;
        v[i] = make_pair(a, i);
    }
    sort(v.begin(), v.end(), greater<pair<ll,ll>>());
    vector<vector<ll>> dp(N+1, vector<ll>(N+1));

    for(int i = 1; i < N+1 ; ++i){
        dp[i][0] = dp[i-1][0] + v[i-1].first * abs(v[i-1].second - N + (i-1));
        for(int j = 1 ; j <= i-1 ; ++j){
            dp[i][j] = max(dp[i-1][j] + v[i-1].first * abs(v[i-1].second - N + i - j - 1), dp[i-1][j-1] + v[i-1].first * abs(v[i-1].second - j));
        }
        dp[i][i] = dp[i-1][i-1] + v[i-1].first * abs(v[i-1].second - i);
    }
    ll ret = 0;
    for(int i = 0; i < N+1; ++i){
        ret = max(ret, dp[N][i]);
    }
    cout << ret << endl;

    return 0;


}

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

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define fst first
#define snd second

int main()
{
    int a;
    cin >> a;
    string s;
    cin >> s;

    if(a < 3200)
        cout << "red";
    else
        cout << s;

    return 0;
}


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

int f(int s){
  if(s%2==0){
    return s/2;
  }
  else{
    return 3*s+1;
  }
}

int main(){
  int s;
  cin>>s;
  set<int> S;
  S.insert(s);
  bool frag=true;

  int i=1;
  while(frag){
    ++i;
    s=f(s);
    if(!S.count(s)){S.insert(s);}
    else{frag=false;}
  }

  cout<<i<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(void){
   int N,D;
   cin>>N>>D;
   vector<vector<int>>X(N,vector<int>(D));
   for(int i=0;i<N;i++){
       for(int j=0;j<D;j++){
           cin>>X[i][j];
       }
   }
   long long int a;
   long long int sum=0;
   int count=0;
   for(int i=0;i<N;i++){
       for(int j=i+1;j<N;j++){
           sum=0;
           for(int k=0;k<D;k++){
               a=abs(X[i][k]-X[j][k])*abs(X[i][k]-X[j][k]);
               sum+=a;
           }
           for(int k=0;k*k<=sum;k++){
               if(k*k==sum){
                   count++;
               }
           }
       }
   }
   cout<<count<<endl;
}


Measured memory_bytes: 256
c = [list(map(int, input().split())) for i in range(3)]
check = 0
a,b = [0]*3,[0]*3

for i in range(2):
  for j in range(2):
    if c[i][j]+c[i+1][j+1] == c[i+1][j]+c[i][j+1]:
      check += 1
if c[0][0]+c[2][2] == c[0][2]+c[2][0]:
  check += 1
      
if check == 5:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#define _LIBCPP_DEBUG 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
typedef vector<int> vi;
typedef long long ll;



int main(){
    ll N,a[100010],b[100010],ato=0,bto=0;
    cin>>N;
    rep(i,0,N){
        cin>>a[i];
        ato+=a[i];
    }
    rep(i,0,N){
        cin>>b[i];
        bto+=b[i];
    }
    if(ato<bto){
        cout<<-1<<endl;
        return 0;
    }
    ll pl[100010],pite=0,mto=0,mcn=0;
    rep(i,0,N){
        if(a[i]>b[i]){
            pl[pite]=a[i]-b[i];
            pite++;
        }
        else if(a[i]<b[i]){
            mto+=b[i]-a[i];
            mcn++;
        }
    }
    if(mto==0){
        cout<<0<<endl;
        return 0;
    }
    sort(pl,pl+pite,greater<>());
    rep(i,0,pite){
        if(i!=0)pl[i]+=pl[i-1];
        if(mto<pl[i]){
            cout<<i+1+mcn<<endl;
            return 0;
        }
    }
    

    
}






Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<28;
const long long MOD =1000000000+7;

int cerch(int start, vector<vector<int>>& path, vector<int>& dp)
{
    int bef=0;
    if(dp[start]==-1){
        for(auto itr=path[start].begin();itr!=path[start].end();itr++){
            chmax(bef,1+cerch(*itr,path,dp));
           // cout << " " << cerch(*itr, path, dp)<<" ";
        }
        dp[start]=bef;
    }
   
    return (dp[start]);
}

int main(){
    int n,m;
    cin >> n>>m;
    int ans=0;
    vector<vector<int>>path(n+1);
    pair<int,int>bef;
    for(int i=0;i<m;i++){
        cin>>bef.first>>bef.second;
        path[bef.first-1].push_back(bef.second-1);
    }
    vector<int>dp(n+1,-1);
    for(int i=0;i<n;i++){
       // cout<<path[i].size()<<" "<<cerch(i,path,dp)<<endl;
        chmax(ans,cerch(i,path,dp));
    }
    cout<<ans;
}


Measured memory_bytes: 8832
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int N;
vector<int> w;

int solve() {
    vector<vector<int>> dp(N+1, vector<int>(N+1, -N));
    for (int i = 0; i <= N; ++i) {
        dp[i][i] = 0;
        if (i < N) dp[i][i+1] = 0;
    }
    for (int bet = 2; bet <= N; ++bet) {
        for (int i = 0; i + bet <= N; ++i) {
            int j = i + bet;
            if (dp[i+1][j-1] == j-i-2) {
                if (abs(w[i] - w[j-1]) <= 1) chmax(dp[i][j], j-i);;
            }
            for (int k = i+1; k <= j-1; ++k) {
                chmax(dp[i][j], dp[i][k] + dp[k][j]);
            }
        }
    }
    return dp[0][N];
}

int main() {
    while (cin >> N, N) {
        w.resize(N);
        for (int i = 0; i < N; ++i) cin >> w[i];
        cout << solve() << endl;
    }
}


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

int main(){
  string S; cin >> S;
  
  bool OK = true;
  if(S.size() <= 7);
  else{
      int lcount = 0;
      for(int i = 0; i < S.size(); i++){
          if(S.at(i) == 'x') lcount++;
      }
      if(lcount >= 8) OK = false;
  }
  if(OK) cout << "YES" << endl;
  else cout << "NO" << endl;
}



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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const ll INF=(ll)1e19;
//const int INF=(1<<30);
//const int INF=(1<<29);

int main(){
  int N,x;
  cin >> N >> x;
  vector<ll> a(N);
  REP(i,N)cin >> a[i];

  ll ans=0;
  REP(i,N-1){
    if(a[i] + a[i+1] > x){
      ans += a[i+1] + a[i] - x;
      a[i+1] = max((ll)0, a[i+1] -(a[i+1] + a[i] - x)); 
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 1024