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

#include <bits/stdc++.h>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define dump(x)  cout << #x << " = " << (x) << endl;

#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
//             0123456789 - digits. check the limits, int vs long
const int MX = 100001;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(0);
    cout << std::fixed;
    // freopen("ex.in","r",stdin);
    // freopen("ex.out","w",stdout);
    int n;
    cin >> n;
    int d[n];
    int sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> d[i];
        sum += d[i];
    }
    int ans = 0;
    for (int i = 0; i < n - 1; i++) {
        sum -= d[i];
        ans += sum * d[i];
    }
    cout << ans << "\n";
    return 0;
}

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define Lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin();

int lbidx(vector<int> &x, int y) {
  return lower_bound(x.begin(), x.end(), y) - x.begin();
};

int upidx(vector<int> &x, int y) {
  return upper_bound(x.begin(), x.end(), y) - x.begin();
};

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N);

  rep(i, 0, N) {
    cin >> A[i];
  }
  rep(i, 0, N) {
    cin >> B[i];
  }

  int ans = 0;
  int T = 1;
  rep(k, 0, 30) {
    int mod = 2 * T;
    vector<int> Amod(N);
    vector<int> Bmod(N);
    rep(i, 0, N) {
      Amod[i] = A[i] % mod;
      Bmod[i] = B[i] % mod;
    }
    sort(All(Amod));

    ll counter = 0;
    rep(i, 0, N) {
      int bi = Bmod[i];
      int l1 = lbidx(Amod, T - bi);
      int r1 = lbidx(Amod, 2 * T - bi);
      int l2 = lbidx(Amod, 3 * T - bi);
      int r2 = lbidx(Amod, 4 * T - bi);
      // int l1 = Lbidx(Amod, T - bi);
      // int r1 = Lbidx(Amod, 2 * T - bi);
      // int l2 = Lbidx(Amod, 3 * T - bi);
      // int r2 = Lbidx(Amod, 4 * T - bi);
      // auto l1 = lower_bound(Amod.begin(), Amod.end(), T - bi);
      // auto r1 = lower_bound(Amod.begin(), Amod.end(), 2 * T - bi);
      // auto l2 = lower_bound(Amod.begin(), Amod.end(), 3 * T - bi);
      // auto r2 = lower_bound(Amod.begin(), Amod.end(), 4 * T - bi);
      counter += (r1 - l1) + (r2 - l2);
    }
    if (counter % 2 == 1) ans += T;
    T *= 2;
  }

  cout << ans << endl;
};


Measured memory_bytes: 3432
#include <iostream>

using namespace std;

int main() {
	int human[5];
	while (cin >> human[0], human[0]) {
		for (int i = 1; i < 5; ++i)
			cin >> human[i];
		
		int hands[3] = {0};
		for (int i = 0; i < 5; ++i)
			hands[human[i]-1] = 1;
		
		int k = 0, no = 0;
		for (int i = 0; i < 3; ++i)
			if (hands[i]) ++k;
			else no = i + 1;
		
		if (k == 2) {
			no = (no + 1) % 3 + 1;
			for (int i = 0; i < 5; ++i)
				if (human[i] == no) cout << "2" << endl;
				else cout << "1" << endl;
		}
		else
			for (int i = 0; i < 5; ++i)
				cout << "3" << endl;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long ll;

const int MAX_N =  2e3+10;

int main(int argc, char const *argv[])
{
	ll N, Z, W;
	ll a[MAX_N];
	cin >> N >> Z >> W;
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
	}

	if (N==1) {
		cout << abs(a[N-1] - W) << endl;
	}
	else {
		cout << max(abs(a[N-2]-a[N-1]), abs(a[N-1]-W)) << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()

using namespace std;

char _S[100010];
int S[100010];
int _dp[100010][13];

//----------1000000007----------
const int MOD = 1000000007;
int add(int a, int b)
{
	return (a + b) % MOD;
}

signed main()
{
	cin >> _S;
	int len = strlen(_S);
	REP(i, len) S[i] = _S[i] == '?' ? -1 : (_S[i] - '0');

	if (S[0] == -1)
	{
		REP(i, 10) _dp[0][i] = 1;
	}
	else
	{
		_dp[0][S[0]] = 1;
	}

	for (int i = 1; i < len; i++)
	{
		if (S[i] == -1)
		{
			for (int k = 0; k < 10; k++)
			{
				for (int j = 0; j < 13; j++)
				{
					int m = (j * 10 + k) % 13;
					_dp[i][m] = add(_dp[i][m], _dp[i - 1][j]);
				}
			}
		}
		else
		{
			for (int j = 0; j < 13; j++)
			{
				int m = (j * 10 + S[i]) % 13;
				_dp[i][m] = add(_dp[i][m], _dp[i - 1][j]);
			}
		}
	}

	cout << _dp[len - 1][5] << endl;
}



Measured memory_bytes: 11264
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fr first
#define sc second
typedef long long ll;
const long long llnrm=LLONG_MAX;
const int nrm=INT_MAX;
const int nrn=INT_MIN;
const int nmax=1e5+5;
const int mod=1e9+7;
using namespace std;
int ans,a,b,c;
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>a>>b>>c;
	if(a==b) cout<<c<<endl;
	if(a==c) cout<<b<<endl;
	if(b==c) cout<<a<<endl;
	return 0;
}





Measured memory_bytes: 256
import java.util.Scanner;
class Main {
	public static void main(String[] args) {
		// r<=x<=(W-r) && r<=y<=(H-r)
		Scanner sc = new Scanner(System.in);
		int x, y, r, w, h;
		w = sc.nextInt();
		h = sc.nextInt();
		x = sc.nextInt();
		y = sc.nextInt();
		r = sc.nextInt();
		if (x >= r && x <= (w - r) && y >= r && y <= (h - r)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 26364
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<iomanip>
using namespace std;
#define iF if(Te)
#define MS(m) memset(m,0,sizeof(m))
#ifdef XS
	#include<De>
	const int Te=1;
#else 
	const int Te=0;
#endif

typedef unsigned U;
typedef pair<int,int > P;
typedef long long ll;
void inp();
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	inp();
	return 0;
}
void inp(){
	int T,n;
	cin>>n>>T;
	int t;
	ll tol=0;
	ll cur = 0;
	while(n--){
		cin>>t;
		int tmp=t-cur;
		if(tmp>T){
			tmp=T;
		}
//		cout<<P(tmp,cur)<<endl;
		tol+=tmp;
		cur=t;
	}
	tol+=T;
	cout<<tol<<endl;
}
//A.cc by xsthunder at Fri May 19 12:58:45 2017


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>

template<typename T>inline bool check_min(T a,T &b){return a<b?b=a,1:0;}
template<typename T>inline bool check_max(T a,T &b){return a>b?b=a,1:0;}

namespace pu
{
	typedef long long ll;
	const int N=201000,MOD=1000000007;
	ll inv(ll x){return x==1?1:(-(MOD/x)*inv(MOD%x)%MOD);}
	ll fact[N],ifact[N];
	ll C(int n,int m){return fact[n]*ifact[m]%MOD*ifact[n-m]%MOD;}

	std::vector<int> V[N];
	int pos[N];
	int n,X,Y;
	void initialize()
	{
		scanf("%d%d%d",&n,&X,&Y);
		for(int i=1,c,x;i<=n;i++)
		{
			scanf("%d%d",&c,&x);
			V[c].push_back(x);
		}
		for(int i=1;i<=n;i++)
			std::sort(V[i].begin(),V[i].end());

		fact[0]=1;
		for(int i=1;i<N;i++)fact[i]=fact[i-1]*i%MOD;
		ifact[N-1]=inv(fact[N-1]);
		for(int i=N-1;i;i--)ifact[i-1]=ifact[i]*i%MOD;
	}
	void getpos()
	{
		int minw=2147483647,w,id=0;
		for(int i=1;i<=n;i++)
		{
			if(V[i].empty())continue;

			w=V[i][0];
			if(w==minw)id=0;
			if(check_min(w,minw))id=i;

			pos[i]=std::upper_bound(V[i].begin(),V[i].end(),X-w)-V[i].begin();
		}

		int dmin=2147483647;

		for(int i=1;i<=n;i++)
		{
			if(V[i].empty())continue;
			if(i==id)continue;

			check_min(V[i][0],dmin);

			w=std::upper_bound(V[i].begin(),V[i].end(),Y-minw)-V[i].begin();

			if(!w)pos[i]=0;
			else check_max(w,pos[i]);
		}

		if(!id)return;

		w=std::upper_bound(V[id].begin(),V[id].end(),Y-dmin)-V[id].begin();
		if(!w)pos[id]=0;
		else check_max(w,pos[id]);
	}
	ll calc()
	{
		int cnt=0;
		ll ret=1;
		for(int i=1;i<=n;i++)cnt+=pos[i];

		for(int i=1;i<=n;i++)
			ret=ret*C(cnt,pos[i])%MOD,cnt-=pos[i];

		return (ret%MOD+MOD)%MOD;
	}
	void solve()
	{
		initialize();
		getpos();
		printf("%lld\n",calc());
	}
}
int main()
{
	pu::solve();
	return 0;
}


Measured memory_bytes: 13184
n = input()
n = int(n)

numbers = input()
numbers = numbers.split(' ')

for i in range(1, n):
    print(" ".join(numbers))
    j = i - 1
    while (j >= 0) and (int(numbers[j]) > int(numbers[j + 1])):
        numbers[j], numbers[j + 1] = numbers[j + 1], numbers[j]
        j -= 1
print(" ".join(numbers))

Measured memory_bytes: 7640
N,K=map(int,input().split())
h=[int(x) for x in input().split()]

dp=[float('inf')]*N
dp[0] = 0

for i, hi in enumerate(h):
  if i > 0:
    x = max(0,i-K)
    dp[i]=min([dpj + abs(hi-hj) for dpj, hj in zip(dp[x:i], h[x:i])])
     
print(dp[N-1])

Measured memory_bytes: 13928
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
#define PI acos(-1)
#define sz 100010
#define RUN_FAST ios::sync_with_stdio(false);
using namespace std;

int main()
{
    //RUN_FAST; cin.tie(nullptr);
    int n, m, i, sum, tmp, cnt;
    scanf("%d %d", &n, &m);
    int arr[n];
    sum=0;
    for (i=0; i<n; i++) {
        scanf("%d", &arr[i]);
        sum+=arr[i];
    }
    tmp=ceil((double)sum/(double)(4*m));
    cnt=0;
    for (i=0; i<n; i++)
        if (arr[i]>=tmp) cnt++;

    if (cnt>=m) puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 3660
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] array = new int[5];
        for(int i = 0; i < 5; i++) {
            array[i] = sc.nextInt();
        }
//        int a = sc.nextInt();
//        int b = sc.nextInt();
//        int c = sc.nextInt();
//        int d = sc.nextInt();
//        int e = sc.nextInt();
        int k = sc.nextInt();
        for(int i = 0; i < 5; i++) {
            for(int j = 0; j < 5; j++) {
                if(Math.abs(array[i]- array[j]) > k) {
                    System.out.println(":(");
                    return;
                }
            }
        }
        System.out.println("Yay!");
    }
}

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

int main(){
    int N,sum=0;
    cin>>N;
    vector<int> d(N);
    for(int i=0;i<N;i++){
        cin>>d.at(i);
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
template<typename T> T gcd(T a,T b){if(a>b)swap(a,b);for(;a>0;b%=a,swap(a,b));return b;}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const ll mod = 10000018033;
const double pi = acos(-1);
const double eps = 1e-10;
int n;
int s[300][300];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  FOR(i, 0, n) FOR(j, 0, n){
    char c;
    cin >> c;
    s[i][j] = c-'a';
  }
  int ans = 0;
  FOR(i, 0, n){
    FOR(j, 0, n)FOR(k, 0, j) if(s[(j+i)%n][k] != s[(k+i)%n][j]) goto l_break;
    ans += n;
    l_break: ;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();  //ダイスの合計
    int K = sc.nextInt();  //振るダイスの数
    int[] p = new int[N];
    for(int i =0; i<K-1; i++)
     p[i] = sc.nextInt();
    double maxAverage = 0;
    double beforeAverage = 0;
	
    //期待値が最大となる組み合わせを探す
    for(int i=0; i< N - (K - 1); i++){
      	p[i + (K-1)] =sc.nextInt();
        double average = 0;
        if(i ==0){
        for(int j=0; j<K; j++)
           average += (p[i+j] + 1) / 2.0;
        }else{
            average = beforeAverage - (p[i -1]+1)/2.0 + (p[i+(K-1)]+1)/2.0;
            //1個前を消してケツを追加
        }
        beforeAverage = average;
        if(maxAverage < average) maxAverage = average;
    }
    System.out.println(maxAverage);
  }
}


Measured memory_bytes: 83212
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int N;
    cin>>N;
    string S[50];
    int cou[50][26]={0};
    for(int i=0;i<N;i++)cin>>S[i];
    for(int i=0;i<N;i++){
        for(int j=0;j<S[i].size();j++){
            cou[i][S[i][j]-'a']++;
        }
    }
    int ans[26];
    for(int i=0;i<26;i++)ans[i]=100000;
    for(int i=0;i<N;i++){
        for(int j=0;j<26;j++){
            ans[j]=min(ans[j],cou[i][j]);
        }
    }
    for(int i=0;i<26;i++){
        for(int j=0;j<ans[i];j++){
            printf("%c",'a'+i);
        }
    }
    puts("");
    return 0;
}


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

int main() {
  int N, D;
  cin >> N >> D;

  cout << N / (2 * D + 1) + min(1, N % (2 * D + 1)) << endl;
  return 0;
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
long long n;
const int MAX = 1e5+5;

int main(){
    int n,m;
    cin >> n >> m;
    vector<pair<int,int>> iv[MAX];
    pair<int,int> ans[MAX];

    int a,b;
    for(int i=1;i<=m;i++){
        cin >> a >> b;
        iv[a].push_back(make_pair(b,i));
    }
    for(int i=1;i<=n;i++){
        sort(iv[i].begin(),iv[i].end());
        int k = 1;
        for(auto c : iv[i]){
            ans[c.second] = make_pair(i,k++);
        }
    }
    for(int i=1;i<=m;i++){
        printf("%.6d%.6d\n",ans[i].first,ans[i].second);
    }

}


Measured memory_bytes: 7808
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef  long long ll;


int main(){
  
  int c[3][3];
  int a[3]={0};
  int b[3]={0};

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

  for(a[0]= 0; a[0]<=100; a[0]++){
    for(a[1]=0; a[1]<=100; a[1]++){
      for(a[2]=0; a[2]<=100; a[2]++){
        for(int i=0; i< 3; i++){
          b[i]=c[i][i]-a[i];
        }
        int flag =1;
        for(int i =0; i < 3; i++){
          for(int j=0; j<3; j++){
            if(c[i][j]!=(a[i]+b[j]))
              flag =0;
          }
        }
        if(flag){
          cout << "Yes" <<endl;
          return 0;
        }
      }
    }
  }

  cout << "No" <<endl;
  return 0;
}




Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
using namespace std;
string a;
int i,o;
bool t;
int main(){
	cin>>a;
	t=false;
	o=a.size();
	for(i=0;i<=o-1;i++){
		if(a[i]=='b'&&a[o-i-1]=='d')continue;
		if(a[i]=='q'&&a[o-i-1]=='p')continue;
		if(a[i]=='d'&&a[o-i-1]=='b')continue;
		if(a[i]=='p'&&a[o-i-1]=='q')continue;
		t=true;break;
	}
	if(t)cout<<"No";
	else cout<<"Yes";
	return 0;
}


Measured memory_bytes: 512
#https://atcoder.jp/contests/abc070/tasks/abc070_c
import fractions
N = int(input())
T = [int(input()) for _ in range(N)]
ans = T[0]
for i in range(1, N):
    ans  = ans * T[i] // fractions.gcd(ans, T[i])
print(ans)

# gcd(a,b) * lcm(a,c) = a, b

Measured memory_bytes: 5048
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<map>
#include<vector>
#include <bitset>
using namespace std;
#define MAX 300000
typedef long long ll;

int main(){
  ll data,ans=0;
  int N,A[110000];
  cin>>N;
  for(int i=0;i<N;i++) cin>>A[i];

  map<int,int> M;
  for(int i=0;i<N;i++){
    M[A[i]]++;
  }

  for(auto x: M){
    if(x.first>x.second) ans+=x.second;
    else ans+=x.second-x.first;
  }
  cout<<ans<<endl;
  
}


Measured memory_bytes: 5120
#include<iostream>
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

int main(){
    string S;cin>>S;
    int N=S.size();
    int i=0;
    ll ans=0;
    while(i<N){
        int l=0;
        while(S[i]=='<' && i<N){
            i++;
            l++;
        }
        int g=0;
        while(S[i]=='>' && i<N){
            i++;
            g++;
        }
        ans+=(ll)l*(l-1)/2+(ll)g*(g-1)/2;
        ans+=(ll)max(l,g);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 900
//-fexec-charset=CP932
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<int>>;
using p=pair<int,int>;
#define MAX 100
#define THOU 1000
#define FIVEMAX 100000
#define NINEMAX 1000000000
#define TWEMAX 1000000000000
#define rep(i,n) for (int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;i>=0;i--)
#define arep(i,a,n) for(int i=a;i<n;i++)
#define darep(i,a,n) for(int i=n,i>=a;i--)
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 ll INF=1LL<<60;
int main(){
 cin.tie(0);
 ios::sync_with_stdio(false);
 ll a,b,c,d;
 cin>>a>>b>>c>>d;
 vector<ll>v;

 v.push_back(a*c);
 v.push_back(a*d);
 v.push_back(b*c);
 v.push_back(b*d);
 sort(v.begin(),v.end());
 cout<<v.at(3);
 return 0;
}

Measured memory_bytes: 3588
// Problem : C - Repsept
// Contest : AtCoder - AtCoder Beginner Contest 174
// URL : https://atcoder.jp/contests/abc174/tasks/abc174_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args&&... args) {
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#define int long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define MOD 1000000007
#define mod 998244353
#define bug cout<<"HY"<<endl
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define numize(A) A.numize(unique(A.begin(), A.end()) - A.begin())
typedef pair<int,int> P;
int power(int a,int b)
{
    if(b==0)
        return 1;
    if(b%2==0)
        return (power((a*a)%mod,b/2))%mod;
    return (a*(power((a*a)%mod,b/2))%mod)%mod;
}
int modInv(int n)
{
    return power(n, MOD-2);
}
int nCr(int n, int r, int p=MOD)
{
   if (r==0)
      return 1;
    int Fact[n+1];
    Fact[0] = 1;
    for (int i=1 ; i<=n; i++)
    {
        Fact[i] = (Fact[i-1]*i)%p;
    }
    return (((Fact[n]* modInv(Fact[r])) % MOD) *(modInv(Fact[n-r]) % MOD)) % MOD;
}
double PI=3.14159265359;
int stringDiv(int num,int k)
{
	// int num=0,i;
	// for(i=0;i<n;i++)
	// {
	num*=10;
	num+=7;
	if(num%k==0)
		return 0;
	num%=k;
	// }
	return num;
}
void solve()
{
	int k,i;
	cin>>k;
	// int num=1;
	// int cnt=1;
	map<int,int> DP;
	int n=1;
	int num=0;
	// cout<<"HY"<<endl;
	while(stringDiv(num,k)!=0)
	{
		// cout<<stringDiv(n,k)<<endl;
		num=stringDiv(num,k);
		// cout<<num<<endl;
		if(DP[num]>0)
		{
			cout<<-1<<endl;
			return;
		}
		DP[num]=1;
		n++;
	}
	cout<<n<<endl;
}
int32_t main()
{
    boost;
    int  t=1;
    // cin>>t;
    while(t--)
    {
    	solve();
    }
}


Measured memory_bytes: 66112
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
#define PI  acos(-1)
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fi first
#define se second
#define pb push_back
#define re return
#define br break

//----***入出力***---
void print() { std::cout << "\n"; }
template <class T>void print(const T &x) {std::cout << x<<"\n";}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;


signed main(){
  int N,A,B;cin>>N>>A>>B;
  N--;A--;B--;
  if((B-A)%2==0){
    int ans=(B-A)/2;
    print(ans);
    re 0;
  }
  if(N-A<=B){
    int ans=N-B;
    // print(ans,A+N-B,(N-(N-A-B)/2),(B-A)/2);
    ans+=(B-A+1)/2;
    print(ans);
  }
  else{
    int ans=A;
    ans+=(B-A+1)/2;
    print(ans);
    
  }

}


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

using namespace std;

#define ll long long 
#define pi 3.14159265358979323
#define mod 1000000007

void solve(){
    int n;
    cin>>n;
    while(n){
        int m = n % 10;
        if(m == 7){
            cout<<"Yes";
            return;
        }
        n /= 10;
    }
    cout<<"No";
}

int main() {
    int t = 1;
    while(t--)
        solve();
    return 0;
}



Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
const int mod = 998244353;

const int maxn = 1e5 + 5;
int d[maxn];
int fi(int x) {
    return d[x] == x ? x : d[x] = fi(d[x]);
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    int ans = n;
    f1 (n) {
        d[i] = i;
    }
    f (m) {
        int x, y, z;
        cin >> x >> y >> z;
        x = fi(x);
        y = fi(y);
        if (x != y) {
            d[x] = y;
            ans--;
        }
    }
    cout << ans << '\n';
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int N;
cin >> N;
vector<int> mon(N);
for(int i = 0; i < N; i++){
    cin >> mon[i];
}
int M = N/2;
int count = 0;
sort(mon.begin(), mon.end());
for(int K = 0; K < 200001; K++){
    if(mon[M-1] < K && mon[M] >= K) count++;
}

cout << count << endl;


}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define endl    '\n'
using namespace std;

typedef long long ll;

int main()
{
    int w, sum;

    cin >> w;

    while (w != -1) {
        sum = 1150;

        if (w > 10) {
            sum += 125 * (min(10, w - 10));
        }

        if (w > 20) {
            sum += 140 * (min(10, w - 20));
        }

        if (w > 30) {
            sum += 160 * (w - 30);
        }

        cout << 4280 - sum << endl;

        cin >> w;
    }

    return 0;
}




Measured memory_bytes: 3080
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#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 <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <cassert>
using namespace std;

#define sz(a) int(a.size())
#define rep(i, s, n)  for(int i = s; i <= n; ++i)
#define rev(i, n, s)  for(int i = n; i >= s; --i)
#define fore(x, a) for(auto &&x : a)
typedef long long ll;
const int mod = 1000000007;
const int N = 100005;

int a[N];

int main() {
#ifdef loc
  if(!freopen((string(FOLDER) + "inp.txt").c_str(), "r", stdin)) {
    assert(0);
  }
  freopen((string(FOLDER) + "out.txt").c_str(), "w", stdout);
#endif
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  while(m-- > 0) {
    int x, y;
    cin >> x >> y;
    a[x]++;
    a[y]++;
  }
  rep(i, 1, n) {
    if(a[i] & 1) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 640
#include<cstdio>

int main() {

	char n[1001];
	int i = 0,sum = 0;
	
	while (true) {
		i = sum = 0;
		scanf("%c", &n[i]);
		if (n[0] == '0') break;
		sum += (n[i] - '0');
		i++;

		while (true) {
			scanf("%c", &n[i]);
			if (n[i] == '\n') break;
			sum += (n[i] - '0');
			i++;
		}
		printf("%d\n", sum);
	}
	return 0;
}

Measured memory_bytes: 964
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define N 100
#define M 99

int top,S[N];
void isEmpty(void);
void push(int);
int pop(void);
void isFull(void);
int main()
{
  int a,b;
  top=0;
  char s[N];
  while(scanf("%s",s) != EOF){
    if (s[0]=='+'){
      a = pop();
      b = pop();
      push(a+b);
    }
    else if(s[0]=='-'){
      b=pop();
      a = pop();
      push(a - b);
    }
    else if(s[0]=='*'){
      a = pop();
      b = pop();
      push(a*b);
    }
    else{
      push(atoi(s));
    }
  }
  printf("%d\n",pop());

  return 0;
}

void push(int a){
  S[++top] = a;
}
int pop(){
  top--;
  return S[top+1];
}

Measured memory_bytes: 548
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()


int main() {
  int n;
  cin >> n;
  ll cnt = 0;
  for (int i = 1; i <= n; i++) {
    if (i%3 != 0 && i%5 != 0)
      cnt += i;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3620
import sys
sys.setrecursionlimit(10**9)

N,M = map(int,input().split())
G = [[] for _ in [0]*N]

for _ in [0]*M:
  a, b, d = map(int, input().split())
  a -= 1
  b -= 1
  G[a].append((b, d))
  G[b].append((a, -d))

X = [None]*N

def dfs(i, x=0):
  for j, d in G[i]:
    if X[j] is None:
      X[j] = x+d
      dfs(j, x+d)
    elif X[j] != x+d:
      print('No')
      exit()

for i in range(N):
  if X[i] is not None:
    continue
  X[i] = 0
  dfs(i)
print('Yes')

Measured memory_bytes: 160908
# -*- coding: utf-8 -*-
import copy

N,M = list(map(int, input().rstrip().split()))
AB_list = [list(map(int, input().rstrip().split())) for i in range(M)]
#-----

vertex_dic = { i: set() for i in range(1,N+1) }

for a,b in AB_list:
    vertex_dic[a].add(b)
    vertex_dic[b].add(a)

def check(c_vertex_dic :dict,c_start :int, c_end :int, passed :list):
# start→endへの経路が存在したらTrueを返す。
# ただし、start→endへの直接の経路は除く
    if c_start == c_end:
        return True
    
    for next in c_vertex_dic[c_start]:
        if next not in passed:
            passed.append(next)

            if check(c_vertex_dic, next, c_end, passed):
                return True
            


checked_dic = { i: set() for i in range(1,N+1) }  # check済みの経路を保存
cnt=0
for start in range(1,N+1):
    for end in vertex_dic[start]:
        if end not in checked_dic[start]:
            checked_dic[start].add(end)
            checked_dic[end].add(start)
            
            # 経路check用として、start→endへの直接の経路を削除したv_dicを用意
            v_dic = copy.deepcopy(vertex_dic)
            v_dic[start].remove(end)
            v_dic[end].remove(start)
        
            if not check(v_dic, start, end, [start]):
                cnt += 1
            
print(cnt)


Measured memory_bytes: 3672
n=int(input())
h=list(map(int,input().split(' ')))
dp=[0] * n
dp[0]=0
dp[1]=abs(h[0]-h[1])
for i in range(2,n):
    dp[i] = min(abs(h[i]-h[i-1])+dp[i-1],abs(h[i]-h[i-2])+dp[i-2])
print(dp[n-1])

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

int max(int a, int b){
	return (a > b)? a : b;
}

int main(){
	string s;
	int N;
	int k;
	int l, r;
	bool J, I;
	int ans = 0;
	
	cin >> s;
	N = s.size();
	
	for(int i = 0; i < N; i++){
		k = 0;
		if(s[i] == 'O'){
			k++;
			while(s[++i] == 'O') k++;
			
			r = i;
			l = i - k - 1;
			I = true; J = true;
			for(int j = 0; j < k; j++){
				if(r + j == N || s[r + j] != 'I'){
					I = false;
					break;
				}
			}
			for(int j = 0; j < k; j++){
				if(l - j < 0 || s[l - j] != 'J'){
					J = false;
					break;
				}
			}
			
			if(I && J){
				ans = max(ans, k);
			}
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 2052
#include<bits/stdc++.h>
using namespace std;
main()
{
  int k;
  cin>>k;
  string s;
  cin>>s;
  int n=s.size();
  if(n<=k)
     cout<<s;
  else
  { 
    string ans=s.substr(0,k);
    string dot="...";
    cout<<ans<<dot;
  }
}

Measured memory_bytes: 3640
#include <iostream>

using namespace std;

int abs(int x) {
  return (x < 0) ? -x : x;
}

int main() {
  int N, L;
  int sum = 0, min = 10000, tmp;
  cin >> N >> L;

  for (int i = 0; i < N; i++) {
    tmp = L+i;
    if (abs(min) > abs(tmp)) min = tmp;
  }
  sum = L*N + N*(N-1)/2;

  cout << sum-min << endl;
  return 0;
}


Measured memory_bytes: 256
object Main extends App {
  import scala.io.StdIn._

  val tg   = "ATCG"
  val line = readLine()

  val result =
    line
      .foldLeft((0, 0)) {
        case ((maxCount, count), c) =>
          if (tg.contains(c)) (Math.max(maxCount, count + 1), count + 1)
          else (maxCount, 0)
      }
      ._1

  println(result)
}


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

int main(){
  int n;
  string s;
  cin>> n >> s;
  int ans=0;
  for (int i=0; i<n-2; i++){
    if (s[i]=='A' && s[i+1]=='B' && s[i+2]=='C') ans++;
  }
  cout<< ans << endl;
                                    
}

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int k;
    cin>>k;
    long long int ans=0;
    for (int i=1;i<=k;i++)
        for (int j=1;j<=k;j++)
            for (int l=1;l<=k;l++)
                ans+=__gcd(__gcd(i,j),l);
    cout<<ans<<"\n";            
	return 0;
}

Measured memory_bytes: 3588
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = 0
for i in range(n):
    if b[i] <= a[i]:
        c = c + b[i]
    else:
        d = min(b[i]-a[i],a[i+1])
        c = c + a[i] + d
        a[i+1] = a[i+1] -d
print(c)

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

using namespace std;

long long inf=1000000007;
long long h,w;

void dfs(long long y,long long x,vector<vector<bool>> &seen,vector<vector<long long>> grid){
	vector<long long> dy={1,1,1,0,0,-1,-1,-1};
	vector<long long> dx={1,0,-1,1,-1,1,0,-1};

	for(long long i=0;i<8;i++){
		long long py=y+dy.at(i);
		long long px=x+dx.at(i);

		if(py<0 || py>=h || px<0 || px>=w || grid.at(py).at(px)==0 || seen.at(py).at(px)) continue;

		seen.at(py).at(px)=true;
		dfs(py,px,seen,grid);
	}
}

int main(){
	cin>>w>>h;

	while(h!=0 || w!=0){
		vector<vector<long long>> grid(h,vector<long long>(w));
		for(long long i=0;i<h;i++){
			for(long long j=0;j<w;j++){
				cin>>grid.at(i).at(j);
			}
		}

		vector<vector<bool>> seen(h,vector<bool>(w,false));
		long long ans=0;

		for(long long i=0;i<h;i++){
			for(long long j=0;j<w;j++){
				if(grid.at(i).at(j)==0 || seen.at(i).at(j)) continue;
				ans++;
				seen.at(i).at(j)=true;
				dfs(i,j,seen,grid);
			}
		}

		cout<<ans<<endl;
		cin>>w>>h;
	}

	return 0;
}



Measured memory_bytes: 50312
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define out(a) cout << a << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)

int main() {
    int a, b;
    cin >> a >> b;
    char s[a][a], t[b][b];
    rep(i, a) rep(j, a) cin >> s[i][j];
    rep(i, b) rep(j, b) cin >> t[i][j];
    rep(i, a) { //sの左上
        rep(j, a) {
            int c = 0;
            rep(k, b) {
                rep(l, b) {
                    if (s[i + k][j + l] == t[k][l]) c++;
                }
            }
            if (c == b * b) {
                out("Yes");
                return 0;
            }
        }
    }
    out("No");
}



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


/// File input & output /////
#define fRead(x)        freopen("x.txt","r",stdin)
#define fWrite(x)       freopen ("x.txt","w",stdout)

#define mt              make_tuple
#define ld              long double
#define ll              long long
#define ull             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define INF             2e16
#define PI              acos(-1.0)
#define mp              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())


#define FASTIO        ios_base::sync_with_stdio(0);cin.tie(nullptr);




///..................Sort by second element in a pair in decending order............. ///
bool SortbySecDesc(const pair<long long,long long > &a, const pair<long long,long long > &b)
{
    return a.second>b.second;
}

///.........................first element of pair in descending order..........................//////
bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}



///.............................................................TEMPLATE................................................./////


//long long  Prime[3000000],nPrime;
//long long  mark[10000002];
//
//void seive(long long int n)
//{
//	long long int i,j,limit=sqrt(n*1.0)+2;
//	mark[1]=1;
//	for(i=4; i<=n ;i+=2)
//	mark[i]=1;
//	Prime[nPrime++]=2;
//	for(i=3; i<=n; i+=2)
//	{
//		if(!mark[i])
//		{
//			Prime[nPrime++]=i;
//			if(i<=limit)
//			{
//				for(j=i*i; j<=n ;j+=i*2)
//				{
//					mark[j]=1;
//				}
//			}
//		}
//	}
//}


ll pos,pos1;


int main()
{
    FASTIO;

    int x , n;

    cin >> x >> n;

    if(n==0)
    {
        cout << x << endl;
        return 0;
    }

    ll a[102];

    ll b[102];

   // MEM(b,-1);


    //MEM(a,-1);


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


    }

    for(int i=x; ; i++)
    {

        int f = 0;


       for(int j=0; j<n;j++)
       {
           if(a[j]==i)
           {
               f = 1;
               break;
           }

       }

       if(f==0)
       {
           pos = i;
           break;
       }
    }

    for(int i=x; ; i--)
    {

        int f = 0;

        for(int j=0; j<n; j++)
        {
            if(a[j]==i)
            {
                f = 1;
                break;
            }
        }

        if(f==0)
        {
            pos1 = i;
            break;
        }
    }

    if(abs(x-pos1)>abs(x-pos))
    {
        cout << pos << endl;
    }
    else
    {
        cout << pos1 << endl;
    }



    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
typedef long long ll;

#define pll pair<ll,ll>
#define ff first
#define snd second
#define pb push_back
#define vll vector<ll>
#define vpll vector<pll>
#define endl "\n"
#define MOD 1000000007
using namespace std;

ll const N = 1e5+1;


void solve()
{
   ll n;
   cin>>n;
   
   map<string,int>m;
   m["AC"] = 0;
   m["RE"] = 0;
   m["TLE"] = 0;
   m["WA"] = 0;
   for(int i=0;i<n;i++)
   {
           string s;
           cin>>s;
           m[s]++;
   }
   
   ll a,b,c,d;
   for(auto itr = m.begin();itr!=m.end();itr++)
   {
          if((*itr).ff=="AC")
          {
                a = (*itr).snd;  
          }
          else if((*itr).ff=="TLE")
          {
                b = (*itr).snd;  
          }
          else if((*itr).ff=="WA")
          {
                c = (*itr).snd;  
          }
          else
          {
                d = (*itr).snd;  
          }
   }
   
   cout<<"AC x "<<a<<endl;
   cout<<"WA x "<<c<<endl;
   cout<<"TLE x "<<b<<endl;
   cout<<"RE x "<<d<<endl;
}
 
int main() {
            ios_base::sync_with_stdio(false);
            cin.tie(NULL);
	    int t=1;
	    //cin>>t;
	    while(t--)
	    {
	            solve();
	    }
	    return 0;
}

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

using namespace std;

int main()
{
	for(int i;cin>>i,i;){
		int n=32,a[32];
		for(int j=0;j<i;j++)	cin>>a[j];
		for(int j=0;n>0;j=(j+1)%i){
			n-=(n-1)%5;
			cout<<n<<endl;
			n-=min(n,a[j]);
			cout<<n<<endl;
		}
	}
	return 0;
}

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

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

			var inputArray = retreiveLongArray();
			var inputCount = 1;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			long N = inputArray[0];

			//1*Nの場合
			var min = Math.Truncate(Math.Log10(N))+1;

			var root = Math.Floor(Math.Sqrt(N));

			for (int i = 2; i <= root; i++) {

				if (N%i==0) {
					var fb = Math.Truncate(Math.Log10(N/i)) + 1;
					min = Math.Min(min, fb);
				}

			}

			//答えの出力
			var ans = min;
			Console.WriteLine(ans);

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}
	}
}

Measured memory_bytes: 28052
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>
#include<bitset>
#include<cassert>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

ll a, b;

int main() {
	cin >> a >> b;
	cout << a * b << endl;
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pll = pair<ll,ll>;
using vpii = vector<pii>;
using vpli = vector<pli>;
using vpll = vector<pll>;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

int main() {
  int N,x;
  cin >> N >> x;
  vl 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]+a[i+1]-x;
      a[i+1]=x-a[i];
      if(a[i+1]<0) {
        a[i]+=a[i+1];
        a[i+1]=0;
      }
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<iostream>
#include<set>
#include<queue>
#include<stack>
using namespace std;
int a,b;
int ans;
bool tp;
int main()
{
	cin>>a>>b;
	ans=-1;
	for(int i=1;i<=1000000;i++)
	{
		int x=i*2/25,y=i/10;
		if(x==a&&y==b)
		{
			tp=true;
			ans=i;
			break;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
/*input
5
138 138 138 138 138
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld long double
#define pii pair<int,int>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define sz(_a) (ll)(_a.size())
#define FILL(n) memset(n,0,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
const ll maxn=100005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
 ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;

ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}
int arr[maxn];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
    priority_queue<double,vector<double>,greater<double>> pq;
    int n;
    cin>>n;
    REP(i,n){
        double x;
        cin>>x;
        pq.push(x);
    }
    while(pq.size()>1){
        double x=pq.top();
        pq.pop();
        double y=pq.top();
        pq.pop();
        pq.push((x+y)/2);
    }
    cout<<fixed<<setprecision(5)<<pq.top();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(),(v).end())
#define RSORT(v) sort((v).rbegin(),(v).rend())
const ll MOD = 1000000007;

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

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}



void solve(long long N){
    cout << 800 * N - 200 * (N /15) << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
def merge(A, left, mid, right):
	global cnt

	L = A[left:mid] + [1000000001]
	R = A[mid:right] + [1000000001]

	i = j = 0
	for k in range(left, right):
		if L[i] <= R[j]:
			A[k] = L[i]
			i += 1
		else:
			A[k] = R[j]
			j += 1
	cnt += right - left

def mergeSort(A, left, right):
	if left + 1 < right:
		mid = (left + right) // 2
		mergeSort(A, left, mid)
		mergeSort(A, mid, right)
		merge(A, left, mid, right)

if __name__ == '__main__':
	n = int(input())
	A = list(map(int, input().split()))
	cnt = 0
	mergeSort(A, 0, n)
	print(*A)
	print(cnt)

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

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define endl '\n'
#define MOD 1000000007
#define mm(arr) memset(arr, 0, sizeof(arr))
#define F first
#define S second
#define int ll

int32_t main(){
    FAST
    int n; cin >> n;
    map<string, int> has;
    string arr[n];
    for(int i = 0; i < n; i++){
        string s; cin >> s;
        sort(s.begin(), s.end());
        arr[i] = s;
        has[s]++;
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        ans += has[arr[i]]*(has[arr[i]] - 1)/2;
        has[arr[i]] = 1;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 14548
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007 
#define ll long long 
#define N 3005
#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define piii pair<int, pii>
#define print(x) cout << #x << "=" << x << "\t";
#define endl "\n"
#define newline cout << endl;

string s;
string t;
int m;
int n;
int dp[N][N];

int main() {
    ios::sync_with_stdio(false); cin.tie(NULL); 
    cin >> s >> t;
    m = (int)s.length();
    n = (int)t.length();
    s = " " + s;
    t = " " + t;
    for(int i=1;i<=m;i++)
        for(int j=1;j<=n;j++)
            dp[i][j] = (s[i] == t[j] ? dp[i - 1][j - 1] + 1 : max(dp[i - 1][j], dp[i][j - 1]));

    string ans = "";
    int y = m;
    int x = n;
    while (y > 0 && x > 0) {
        if (s[y] == t[x]) {
            ans += s[y];
            y--;
            x--;
        }
        else if (dp[y - 1][x] > dp[y][x - 1])
            y--;
        else 
            x--;
    }
    reverse(all(ans));
    cout << ans;
    return 0;
}


Measured memory_bytes: 35456