akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const ll max_n = 2500010;
const ll mod = 1000000007;
vector<ll> fac(max_n);
vector<ll> ifac(max_n);

ll mpow(ll x, ll n){
    ll ans = 1;
    while(n){
        if(n % 2){
            ans = ans * x % mod;
        }
        x = x * x % mod;
        n >>= 1;
    }
    return ans;
}

ll comb(ll a, ll b){
    if(a == 0 && b == 0) return 1;
    if(a < 0 || b < 0) return 0;
    if(a < b) return 0;
    ll tmp = ifac[b] * ifac[a-b] % mod;
    return tmp * fac[a] % mod;
}



int main(){
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
    ll X, Y;cin>>X>>Y;
    if((X+Y) % 3 != 0){
        cout << 0 << endl;
        return 0;
    }

    ll a = (2 * Y - X) / 3;
    ll b = (2 * X - Y) / 3;

    ll N = X+Y;
    fac[0] = 1;
    ifac[0] = 1;
    REP(i,N){
        fac[i+1] = fac[i] * (i+1) % mod; // fac[i] = n! % mod;
        ifac[i+1] = ifac[i] * mpow(i+1,mod-2) % mod; // ifac[i] = (i!) * pow(i, mod-2) % mod;
    }

    cout << comb(a+b,a) << endl;

}

Measured memory_bytes: 39296
#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;
#define FASTIO cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define ll long long int


// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;

// struct compare {
// 	bool operator() (const pair<int, int> &a, const pair<int, int> &b) const {
// 		if ((a.S - a.F) != (b.S - b.F)) return ((a.S - a.F) > (b.S - b.F));
// 		else return (a.F < b.F);
// 	}
// };

const int mx = 305;
double ev[mx][mx][mx];
int n;

double calc(int a, int b, int c) {
	if (ev[a][b][c] != -1) return ev[a][b][c];
	double ans = 0;
	if (a != 0) {
		ans += (double)a / n * calc(a - 1, b, c);
	}
	if (b != 0) {
		ans += (double)b / n * calc(a + 1, b - 1, c);
	}
	if (c != 0) {
		ans += (double)c / n * calc(a , b + 1, c - 1);
	}
	ans += 1;
	ans *= (double)n / (a + b + c);
	ev[a][b][c] = ans;
	return ans;
}

int main() {
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
	FASTIO;
	cin >> n;
	vector<int> cnt(4);
	for (int i = 0; i < n; i++) {
		int temp; cin >> temp;
		cnt[temp]++;
	}
	for (int i = 0; i < mx; i++) {
		for (int j = 0; j < mx; j++) {
			for (int k = 0; k < mx; k++) {
				ev[i][j][k] = -1;
			}
		}
	}
	ev[1][0][0] = n;
	ev[0][0][0] = 0;
	double ans = calc(cnt[1], cnt[2], cnt[3]);
	printf("%.10lf\n", ans);

}

Measured memory_bytes: 222080
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>


int main() {
	std::string S, T;
	std::cin >> S;
	std::cin >> T;
	std::vector<std::string> candidates;

	for (unsigned int i = 0; i < S.length() - T.length() + 1; i++) {
		std::string new_S = S;
		bool flag = true;
		for (unsigned int j = 0; j < T.length(); j++) {
			if (S[i + j] == T[j] || S[i + j] == '?') {
				new_S[i + j] = T[j];
			}
			else {
				flag = false;
				break;
			}
		}
		if (flag == true) {
			for (unsigned int i = 0; i < new_S.length(); i++) {
				if (new_S[i] == '?') {
					new_S[i] = 'a';
				}
			}
			candidates.push_back(new_S);
		}
	}

	if (candidates.size() > 0){
		std::sort(candidates.begin(), candidates.end());
		std::cout << candidates.front() << "\n";
	}
	else {
		std::cout << "UNRESTORABLE" << "\n";
	}

}

Measured memory_bytes: 256
#include <cstdio>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int N, temp;
    int a[9]={0};
    scanf("%d", &N);
    for(int i=0; i!=N; i++){
        scanf("%d", &temp);
        if(temp>=3200) a[8]++;
        else a[temp/400]++;
    }
    int cnt=0;
    for(int i=0; i!=8; i++) if(a[i]!=0) cnt++;
    if(cnt==0){
        printf("1 %d\n", a[8]);
    }else printf("%d %d\n", cnt, cnt+a[8]);
        return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(){
	int a;
	int b;
	int x;
	int y;
	while(1){
		scanf("%d %d",&a,&b);
		if(a==0&&b==0)break;
		for(x=0;x<a;x++){
			for(y=0;y<b;y++){
				if(x==0||y==0||x==a-1||y==b-1){
				printf("#");}else{
					printf(".");}
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

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

using namespace std;

int main(void){
    int n, x;

    cin >> n >> x;

    vector<int> a(n);

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

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

    int num = 0;

    for (int i = 0; i < n; i++){
        x -= a[i];
        if (x <= 0){
            if (x == 0)
                num++;
            break;
        }
        else {
            if (i == n - 1 && x != 0)
                num--;
            num++;
        }
    }

    cout << num << endl;
}

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

int main(){
	int H,W;
	scanf("%d%d",&H,&W);
	int *a;
	a = (int*)malloc(H*W*sizeof(int));
	int num=0;
	int n=0;
	int y=0;
	int *b;
	b = (int*)malloc((H*W)*sizeof(int));


	scanf("%d",&num);
	for(int i=0;i<num;i++){
		scanf("%d",&a[i]);
	}

	for(int u=0;u<num;u++){
		y = a[u];
		for(int m=0;m<y;m++){
			b[n] = u+1;
			n++;
		}
	}
	int k=0,Line=0;
	while(Line<H){
		if(Line%2==0){
			k=Line*W;
			for(int i=0;i<W;i++){
				printf("%d ",b[k+i]);
				fflush(0);	/*バッファにためている分を出力*/
			}
		}else{
			k=Line*W+W-1;
			for(int i=0;i<W;i++){
				printf("%d ",b[k-i]);
				fflush(0);	/*バッファにためている分を出力*/
			}
		}
	printf("\n");
	Line++;
	}


	free(a);
	free(b);

	return 0;
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            long X = cin.ReadLong;
            long Y = cin.ReadLong;
            int a = 1;
            X*=2;
            while(X<=Y){
                a++;
                X*=2;
            }
            WriteLine(a);

        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator =' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}

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

using namespace std;
using ll = long long int;

int main(void) {
    cout << fixed << setprecision(16);

    ll n, m;
    cin >> n >> m;
    vector<tuple<ll,ll,ll>> es(m);
    for(ll i=0; i<m; i++) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        es[i] = make_tuple(a, b, -c);
    }

    vector<ll> dis(n, 1e15);
    dis[0] = 0;

    {
        ll i;
        for(i=0; i<n; i++) {
            bool ok = true;
            for(auto &e: es) {
                ll a, b, c;
                tie(a, b, c) = e;
                if(dis[a] + c < dis[b])
                    dis[b] = dis[a]+c, ok = false;
            }
            if(ok) break;
        }
        for(i=0; i<n; i++) {
            bool ok = true;
            for(auto &e: es) {
                ll a, b, c;
                tie(a, b, c) = e;
                if(dis[a] + c < dis[b]) {
                    if(b == n-1) {
                        cout << "inf" << endl;
                        return 0;
                    }
                    dis[b] = dis[a]+c, ok = false;
                }
            }
            if(ok) break;
        }
        cout << -dis[n-1] << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int P[31000]; vector<int>prime;
int p[31000]; int M = 30000;
int main() {
	p[0] = 1; p[1] = 1;
	for (int i = 2; i*i <= M; i++) {
		for (int j = i*i; j <= M; j += i)p[j] = 1;
	}
	for (int i = 0; i <= M; i++) { if (p[i] == 0)prime.push_back(i); }
	for (int i = 0; i < prime.size(); i++) {
		for (int j = i; j < prime.size(); j++) {
			for (int k = j; k < prime.size(); k++) {
				int v = prime[i] + prime[j] + prime[k];
				if (v > M)continue;
				if (prime[i] + prime[j] <= prime[k])continue;
				P[v]++;
			}
		}
	}
	int n;
	while (true) {
		cin >> n; if (n == 0)break;
		cout << P[n] << endl;
	}
	return 0;
}

Measured memory_bytes: 3360
/*
    CP Submission
*/

#include<bits/stdc++.h>

using namespace std;

/* Shortcuts */
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
#define val(x) cout << #x << ": " << (x) << endl;
#define log(x) cout << (x) << endl;
#define sz(x) (int)(x.size())

/* typedefs */
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<string,int> si;
typedef pair<int,ii> iii;
typedef vector <si> vsi;
typedef vector <ii> vii;
typedef vector <int> vi;
typedef vector <vi> vvi;
typedef vector <char> vc;
typedef vector <string> vs;
typedef map <string,vs> msvs;
typedef map <string,int> msi;
typedef map <string,string> mss;

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n; cin >> n;
    ll sum = 0;
    int x;
    for(int i = 0; i < n; i++){
        cin>>x;
        sum += x - 1;
    }
    log(sum);

    return 0;
}


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

bool is_prime(int n) {
	if (n==1) return false;
	else {
		bool flag = true;
		for(int i=2;i*i<=n;i++)
			if (n%i==0) flag = false;
		return flag;
	}
}

int main() {
	int n;
	ll p = 1e9+7;
	cin >> n;
	vector<int> bai(n+1,0);
	vector<int> prime;
	for(int i=2;i<=n;i++) if (is_prime(i)) prime.push_back(i);
	for(int i=2;i<=n;i++) {
		int m = i;
		int idx_p = 0;
		while(m>1) {
			if (m%prime[idx_p]==0) {
				m/=prime[idx_p];
				bai[prime[idx_p]]++;
			}
			else idx_p++;
		}
	}
	ll ans = 1;
	for (ll i=2;i<=n;i++) {
		ans = (ans * (ll)(bai[i]+1)) % p;
		//printf("%d %d\n", i, bai[i]);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
using Graph = vector<vector<pair<int,int>>>;//次の位置、距離


signed main() {
    int N;
    cin >> N;
    Graph G(N);
    for (int i = 0; i < N - 1; i++) {
        int u,v,w;
        cin >> u >> v >> w;
        u--;
        v--;
        G.at(u).push_back({v,w});
        G.at(v).push_back({u,w});
    }
    vector<int> dist(N,-1);
    dist.at(0) = 0;
    queue<int> que;
    que.push(0);
    while (!que.empty()) {
        int current_pos = que.front();
        que.pop();
        for (int i = 0; i < G.at(current_pos).size(); i++) {
            if (dist.at(G.at(current_pos).at(i).first) != -1) continue;
            dist.at(G.at(current_pos).at(i).first) = dist.at(current_pos) + G.at(current_pos).at(i).second;
            que.push(G.at(current_pos).at(i).first);
        }
    }
    for (int i = 0; i < N; i++) {
        cout << (dist.at(i) % 2) << endl;
    }
}

Measured memory_bytes: 11376
//do not think about past and stay in this moment
//organize and work - Abhinav IIITA
#include <bits/stdc++.h>
#include <ctime>
using namespace std;
#define int long long
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end() 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int arr[3000000];
void input(int n){
	for(int i=0;i<n;++i)
	cin>>arr[i];
}
// -----------------------------------------------------------------------



void solve(){
	int n,k,x,y;
	cin>>n>>k>>x>>y;
	int t=min(n,k);n-=t;k-=t;
	int ans=0;ans=t*x;
	ans+=n*y;
	cout<<ans;
}


// -----------------------------------------------------------------------


int32_t main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); 	
	int t=1;
//	cin>>t;
	while(t--)
	solve();
	return 0;
}


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

int main()
{
   	cout << fixed << setprecision(20);

   	long long a,b,c; 
   	cin >> a >> b >> c;
   
   	long long d=c-a-b;
   
   	if(0<d && d*d>4*a*b) 
   		cout << "Yes" << endl;
   	else 
	   	cout << "No"<<endl;
}

Measured memory_bytes: 256
using System;

namespace AtCoder
{
    class Class1
    {
        static void Main(string[] args)
        {
            int A, P;

            string[] input = Console.ReadLine().Split(' ');

            A = int.Parse(input[0]);
            P = int.Parse(input[1]);

            A = A * 3;
            P = P + A;

            Console.WriteLine(P / 2);

        }
    }
}


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

int main()
{
	string s;
	cin>>s;
	int res=0;
	int cnt=0;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='0')cnt++;
		if(s[i]=='1')res++;
	}
	cout<<min(res,cnt)*2<<endl;
	return 0;
}

Measured memory_bytes: 512
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        String str;
        if(a < b){
            str = "a < b";
        }else if(a == b){
            str = "a == b";
        }else{
            str = "a > b";
        }
        
        System.out.println(str);
    }
}



Measured memory_bytes: 26344
#include<iostream>
using namespace std;
#include<bits/stdc++.h>
int main(){
  int x,sum=0,last=0;
  for(int i=0;i<5;i++){
    cin>>x;
    sum=sum+((x+9)/10)*10;
    if(x%10==0)
      continue;
    last=max(last,10-x%10);
  }
  cout<<sum-last;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(a); i++)
typedef long long ll;
const string yes = "Yes";
const string no = "No";

int main()
{
  string n; cin >> n;
  if (n[0]=='7'||n[1]=='7'||n[2]=='7') cout << yes << endl;
  else cout << no << endl;

  return 0;
}


Measured memory_bytes: 3632
from bisect import bisect_left, bisect_right
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort()
b.sort()
c.sort()
ans = 0

for j in b:
    i = bisect_left(a, j)
    k = bisect_right(c, j)
    ans += i*(n-k)
    #print(j, a, i)
    #print(j, c, k)
print(ans)




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

int k;
int aa[110];
int dp[110][5];

int dfs(int pos, int cnt, bool limit)//state标记上一位是不是6 是6我们需要进行特判了
{
    if(cnt<0)   return 0;
	if (pos == 0 && cnt == 0)  return 1;
	//处理完数字个位 表明这个车牌是可以用的 可以先往下看
	//这毕竟是一个递归出口直接看容易晕
	//!limit 是因为当我们处理到limit时 处理方法不一样
	if (!limit&& dp[pos][cnt] != -1) //如果这一位开头的已经处理过了 直接返回结果就行
		return dp[pos][cnt];
	int up = limit ? aa[pos] : 9;
	//limint为假时下一位最高位为9 比如我们处理3xx的时候limit一直假
	int  ans = 0;
	for (int i = 0; i <= up; i++)
	{
        ans += dfs(pos - 1, cnt- (i != 0), limit && i == up);
			//这一位是不是最高位且上一位是不是取到最高位
			//为什么要看前一位是不是最高位呢 我们看处理三百二十里面有多少满足条件的时候肯定320-329都要看看  因为整个300-399都是小于525的
	}
	if (!limit) //不是最高位就记录
		dp[pos][cnt] = ans;//对此为的结果进行记录 方便以后再次利用
	//注意state是因为这一位是不是6 影响着后面的结果
	// return到最后返回了每一位的值
	return ans;
}
int solve(string s)
{
	int n = s.size();//s记录t的位数
    for(int i=0;i<n;++i){
        aa[n-i] = s[i]-'0';
    }
	// while (t != 0)
	// {
	// 	aa[++s] = t % 10;
	// 	t /= 10;
	// }
	return dfs(n, k, true);
}
int main()
{
    string s;
	memset(dp, -1, sizeof(dp));
    cin >> s >> k;
    cout << solve(s)<< endl;
}


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

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

#define ll long long
#define ld double
#define pii pair<ll,ll>
#define vl vector<ll>
#define vb vector<bool>
#define vs vector<string>
#define vp vector<pii>
#define pb push_back
#define mp make_pair
#define sc(a) scanf("%lld",&a);
#define sd(a) scanf("%lf",&a);
#define test() ll tt;cin>>tt;for(ll testcase=1;testcase<=tt;testcase++)
#define all(v) v.begin(),v.end()
#define vivek_ghosh ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MAX 1000055
#define mod 1000000007
#define ff first
#define ss second
const int INF=0x3f3f3f3f;

ll power(ll x,ll n,ll M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return power((x*x)%M,n/2,M);
    else
        return (x*power((x*x)%M,(n-1)/2,M))%M;
}

ll modinv(ll a,ll m)
{
    ll g =__gcd(a, m);
    ll res=power(a, m-2, m);
    return res;
}

vb prime(MAX,true);
vl prm;
void sieve()
{
	prime[0] = prime[1] = false;
	for(ll p=2;p*p<MAX;p++)
	{
		if(prime[p])
		{
			for(ll i=p*p;i<MAX;i+=p)
				prime[i] = false;
		}
	}
	for(ll p=2;p<MAX;p++)
	{
		if(prime[p])
			prm.pb(p);
	}
}

ll n,m,t,i,j,k,q,x,y,ans=0,cnt=0,sum=0,mx=-1,mn=INT_MAX;
string s;

int main()
{
	vivek_ghosh;
	
	ll d;
	cin>>n>>d;
	
	vector<ld> vec[n];
	for(i=0;i<n;i++)
	{
		for(j=0;j<d;j++)
		{
			cin>>k;
			vec[i].pb(k);
		}
	}
	
	
	
	for(i=0;i<n;i++)
	{
		for(j=i+1;j<n;j++)
		{
			ld dis = 0;
			for(k=0;k<d;k++)
			{
				dis += pow(vec[i][k]-vec[j][k],2);
			}
			
			ll temp = sqrt(dis);
			if((temp*temp) == dis)
				ans++;
		}
	}
	cout<<ans<<endl;
	
	
	
	
	

	
	return 0;
}






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

int main(){
	double x1,x2,y1,y2,kyori;
	char input[128],*p;
	
	fgets(input,sizeof input,stdin);
	p=strtok(input," ");
	x1=strtod(p,NULL);
	p=strtok(NULL," ");
	y1=strtod(p,NULL);
	p=strtok(NULL," ");
	x2=strtod(p,NULL);
	p=strtok(NULL," ");
	y2=strtod(p,NULL);
	
	printf("%.6f\n",hypot(fabs(x1-x2),fabs(y1-y2)));
	return 0;
}

Measured memory_bytes: 600
import java.io.*;
import java.util.*;

class Main{
    public static void main(String[] args) throws Exception{
	int i = 0;
	int tmp;
	int Count_Sort = 0;
	boolean flag = true;
	
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	String N_str = br.readLine();
	int N = Integer.parseInt(N_str);

	int[] A;
	A = new int[N];
	
	String A_str = br.readLine();
	Scanner sc = new Scanner(A_str).useDelimiter("\\s* \\s*");
	
	while(sc.hasNext()){
	    A[i] = sc.nextInt();
	    i++;
	}

	i = 0;
	
	while(flag){
	    flag = false;
	    for(int j=N-1;i<j;j--){
		if(A[j]<A[j-1]){
		    tmp = A[j];
		    A[j] = A[j-1];
		    A[j-1] = tmp;
		    flag = true;
		    Count_Sort++;
		}
	    }
	    i++;
	}
	
	for(i=0;i<N;i++){
	    System.out.print(A[i]);
	    if(i!=N-1) System.out.print(" ");
	}
	
	System.out.println("");
	System.out.println(Count_Sort);
	sc.close();
    }
}


Measured memory_bytes: 26340
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define for1(i, a, b) for(i = a; i <= b; ++i)
#define for0(i, a, b) for(i = a; i < b; ++i)
#define forw1(i, a, b) for(i = a; i >= b; --i)
#define forw0(i, a, b) for(i = a - 1; i >= b; --i)
#define fora(v, a) for(auto v : a)
#define bp __builtin_popcount
#define bpll __builtin_popcountll

using namespace std;
using cd = complex<double>;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<cd> vcd;
typedef vector<ii> vii;
typedef vector<vector<int> > vvi;

const int modd1 = 1e9 + 7, modd2 = 998244353, maxn = 10;
const double pi = acos(-1);

void solve(){
    int n, a, b;
    cin >> n >> a >> b;
    int ck = a + b;
    int t1 = n / ck;
    t1 *= a;
    int t2 = n % ck;
    t2 = min(t2, a);
    cout << t1 + t2;
}

signed main() {
    //freopen(".INP", "r", stdin); 
    //freopen(".OUT", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    solve();
}

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

string s;
int ans = 0;

int judge(int jc, int oc, int ic)
{
  if(jc < oc || oc > ic)
    return 0;
  return oc;
}

int main()
{
  cin >> s;
  int status = 0;
  int jc = 0, oc = 0, ic = 0;
  for(int i = 0; i < s.size(); i++){
    switch(status){
    case 0:
      if(s[i] == 'J'){
	jc = 1;
	status = 1;
      }
      break;
      
    case 1:
      if(s[i] == 'J')
	jc++;
      else if(s[i] == 'O'){
	oc = 1;
	status = 2;
      }
      else
	status = 0;
      break;
      
    case 2:
      if(s[i] == 'J'){
	jc = 1;
	status = 1;
      }
      else if(s[i] == 'O')
	oc++;
      else{
	ic = 1;
	status = 3;
      }
      break;
      
    case 3:
      if(s[i] == 'J'){
	ans = max(ans, judge(jc, oc, ic));
	jc = 1;
	status = 1;
      }
      else if(s[i] == 'O'){
	ans = max(ans, judge(jc, oc, ic));
	status = 0;
      }
      else
	ic++;
      break;
    }
    if(status == 3)
      ans = max(ans, judge(jc, oc, ic));
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;
typedef long long int LL;
typedef long long int LLint;
typedef pair<int,int> intpair;
typedef pair<bool,bool> boolpair;
typedef pair<string,string> strpair;
typedef pair<LL,LL> LLpair;
typedef pair<double,double> doublepair;
typedef pair<float,float> floatpair;
typedef vector<int> intvector;
typedef vector<bool> boolvector;
typedef vector<string> strvector;
typedef vector<LL> LLvector;
typedef vector<double> doublevector;
typedef vector<float> floatvector;
#define wait(sec) usleep((sec) * 1000000)
#define ED return 0;
#define TEST cout << "OK" << endl;
#define UP(a,b) ((a+(b-1))/b)
#define SORT(vec) sort(vec.begin(),vec.end());
#define DOUBLECHANGE(count) cout << setprecision(count);
#define REV(vec) reverse(vec.begin(),vec.end());
#define ipow(x,y) LL(pow(x,y))
#define INF 999999999
const long long mod = 1000000007;

int main(){
//    random_device rnd;
//    mt19937 mt(rnd());
      cin.tie(0);
      ios::sync_with_stdio(false);
      vector<int> mod13 (6);
      mod13 = {1,10,9,12,3,4};
      string S;
      cin >> S;
      int N = S.size();
      vector<vector<int>> dp (N+1,vector<int>(13,0));//dp[a][b] = a桁目まで考えたときに余りがbになる数
      dp[0][0] = 1;
      for(int i = 0;i < N;i++){
          if(S[i] != '?'){
//              cout << "NUM is coming" << endl;
              int num = S[i]-'0';
              for(int j = 0;j < 13;j++){
                  dp[i+1][(j+mod13[(N-i-1)%6]*num)%13] += dp[i][j];
                  dp[i+1][(j+mod13[(N-i-1)%6]*num)%13] %= mod;
              }
          }
          else{
//              cout << "? is coming" << endl;
              for(int j = 0;j < 13;j++){
                  for(int k = 0;k < 10;k++){
                      dp[i+1][(j+mod13[(N-i-1)%6]*k)%13] += dp[i][j];
                      dp[i+1][(j+mod13[(N-i-1)%6]*k)%13] %= mod;
                  }
              }
          }

//          for(int j = 0;j < 13;j++){
//              cout << dp[i][j] << "(" << j << ") ";
//          }
//          cout << endl;
      }

//      for(int j = 0;j < 13;j++){
//          cout << dp[N][j] << "(" << j << ") ";
//      }
//      cout << endl;

      cout << dp[N][5] << endl;
}


Measured memory_bytes: 8912
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
typedef long long ll;
int main() {
	int a[3];
	for (int i = 0;i < 3; i++)
		cin >> a[i];
	int f = 0, s = 0;
	for (int i = 0; i < 3; i++) {
		if (a[i] == 5)
			f++;
		else if (a[i] == 7)
			s++;
	}
	if (f == 2 && s == 1)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}

Measured memory_bytes: 256
// https://beta.atcoder.jp/contests/agc020/submissions/1981733
// user : onion_cyc
#include<cstdio>
#include<algorithm>
using namespace std;
int T,k,n,a,b,c,d;
int main(){
	scanf("%d",&T);
	while(T--){
		scanf("%d%d%d%d",&a,&b,&c,&d);n=a+b;
		int l=0,r=n+1,mid,A,B;k=(max(a,b)-1)/(min(a,b)+1)+1;;
		while(l<r){
			mid=(l+r)>>1;
			A=a-mid/(k+1)*k-mid%(k+1);B=b-mid/(k+1);
			if(B<=1ll*A*k)l=mid+1;else r=mid;
		}
		A=a-l/(k+1)*k-l%(k+1);B=b-l/(k+1);r=l+B-A*k+1;
		for(int i=c;i<=min(d,l);i++)putchar(i%(k+1)?'A':'B');
		for(int i=max(c,l+1);i<=d;i++)putchar((i-r)%(k+1)?'B':'A');
		puts("");
	}
	return 0;
}//ONION_CYC QwQ

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

#define MAX 100

int get_top_height(int N, int Cx, int Cy, vector<int> &x, vector<int> &y, vector<int> &h);
int get_height(int H, int X, int Cx, int Y, int Cy);
int judge_center(int N, int Cx, int Cy, vector<int> &x, vector<int> &y, vector<int> &h);

int main(){
    int N;
    cin >> N;
    vector<int> x(N), y(N), h(N);

    for (int i = 0; i < N; ++i) cin >> x[i] >> y[i] >> h[i];

    for (int tmp_x = 0; tmp_x <= MAX; ++tmp_x){
        for (int tmp_y = 0; tmp_y <= MAX; ++tmp_y){
            int H = judge_center(N, tmp_x, tmp_y, x, y, h);
            if (H != -1){
                cout << tmp_x << " " << tmp_y << " " << H << endl;
                return 0;
            }
        }
    }
    return 0;
}

int judge_center(int N, int Cx, int Cy, vector<int> &x, vector<int> &y, vector<int> &h){
    int tmp_H = get_top_height(N, Cx, Cy, x, y, h);
    for (int i = 0; i < N; ++i){
        if (h[i] != get_height(tmp_H, x[i], Cx, y[i], Cy)) return -1;
    }
    return tmp_H;
}

int get_top_height(int N, int Cx, int Cy, vector<int> &x, vector<int> &y, vector<int> &h){
    for (int i = 0; i < N; ++i){
        if (h[i] > 0) return h[i] + abs(x[i] - Cx) + abs(y[i] - Cy);
    }
    return 0;
}

int get_height(int H, int X, int Cx, int Y, int Cy){
    return max(H - abs(X - Cx) - abs(Y - Cy), 0);
}

Measured memory_bytes: 256
prev = 4280
while True:
    cur = 0
    m = int(input())
    if m < 0:
        break

    if m <= 10:
        cur = 1150
    elif m <= 20:
        cur = 1150 + (m-10)*125
    elif m <= 30:
        cur = 1150 + 1250 + (m-20)* 140
    else:
        cur = 1150 + 1250 + 1400 + (m-30) * 160
    print(prev-cur)
    #prev = cur



Measured memory_bytes: 5588
using System;
using System.Collections.Generic;
using System.Linq;

namespace c
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = long.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(i => long.Parse(i)).ToArray();

            var d = new Dictionary<long, long>();
            for(var i = 0; i < n; i++){
                if(d.ContainsKey(a[i])){
                    d[a[i]] += 1;
                }else{
                    d.Add(a[i], 1);
                }
            }

            var s = d.Where(x => x.Value >= 2).OrderByDescending(x => x.Key).Take(2).ToArray();

            if(s.Any()){
                if(s[0].Value >= 4){
                    Console.WriteLine((s[0].Key * s[0].Key));
                }else if(s.Count() == 2){
                    Console.WriteLine((s[0].Key * s[1].Key));
                }            
            }else{
                Console.WriteLine(0);
            }
        }
    }
}


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

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

	int l[n],ans=0;
	for (int i = 0; i < n; i++){
		cin>>l[i];
	}

	sort(l,l+n,greater<int>());

	for (int i = 0; i < k; i++){
		ans+=l[i];
	}

	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int a,b,c,k;
  cin>>a>>b>>c>>k;
  Int x=max({a,b,c});
  Int s=a+b+c-x;
  for(Int i=0;i<k;i++) x<<=1;
  cout<<s+x<<endl;
  return 0;
}


Measured memory_bytes: 256
function main()
  
  S = split(chomp(readline())," ")
  
  A = split(S[1],"")
  B = split(S[2],"")
  C = split(S[3],"")
  
  if A[end] == B[1] && B[end] == C[1]
    println("YES")
  else
    println("NO")
  end
  
end

main()

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

int main()
{
  unordered_set<string> t;
  int n;
  string s;
  cin>>n;
  while(n--)
  {
    cin>>s;
    if(t.find(s) == t.end())
      t.insert(s);
  }
  cout<<t.size()<<"\n";
  return 0;
}

Measured memory_bytes: 17772
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string rstring(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T rtype(T)(){ return rstring.to!T; } alias rint = rtype!int, rlong = rtype!long, rreal = rtype!real;
T[] rtypes(T)(int n){ return n.iota.map!(i => rtype!T()).array; } alias rint = rtypes!int, rlong = rtypes!long, rreal = rtypes!real;
T[][] rtypess(T)(int n, int m){ return n.iota.map!(i => rtypes!T(m)).array; } alias rint = rtypess!int, rlong = rtypess!long, rreal = rtypess!real;

// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

void solve(){
	int n = rint;
	X[] as;
	foreach(i; 0 .. n){
		as ~= X(rlong, rlong);
	}
	
	long[] bs;
	long ans;
	foreach(a; as){
		if(1){
			long l = a.length % 9;
			if(l == 0) l = 9;
			foreach(i; 0 .. l) bs ~= a.digit;
			ans += (a.digit + 9) * ((a.length - l) / 9);
			log("a:", a, "ans:", ans);
		}
		else{
			foreach(i; 0 .. a.length) bs ~= a.digit;
		}
	}
	log("bs:", bs);
	
	ans -= 1;
	long x;
	foreach(b; bs){
		if(x + b < 10) x = x + b, ans += 1;
		else x = x + b - 9, ans += 2;
		log("b:", b, "x:", x, "ans:", ans);
	}
	
	ans.writeln;
	
}
struct X{
	long digit;
	long length;
}

/*
実は、左から順に消していけば良い。
同じ数字が続くところはシミュレーションしておく。周期になるはず。
周期とその時の回数はこう
	int[] zs = [1, 9, 9, 3, 9, 9, 3, 9, 9, 1];
	int[] ys = [9, 10, 11, 4, 13, 14, 5, 16, 17, 2];
	
つまり周期9で, 9 + i をたせばよい

*/


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

int main(){
  int N,M,x;
  cin >> N >> M;
  priority_queue<int> Q;
  for(int i=0;i<N;i++){
    cin >> x;
    Q.push(x);
  }
  for(int i=0;i<M;i++){
    x=Q.top();
    Q.pop();
    Q.push(x/2);
  }
  long long ans=0;
  for(int i=0;i<N;i++){
    ans += Q.top();
    Q.pop();
  }
  cout << ans << endl;
}

Measured memory_bytes: 892
using System;
using System.Linq;
using System.Collections.Generic;

public class Program
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var xs = Console.ReadLine().Split()
            .Select(x => long.Parse(x))
            .OrderByDescending(x => x)
            .ToArray();

        var power = 0L;
        for (int i = 0; i < n; i++)
        {
            power += xs[i * 2 + 1];
        }
        
        Console.WriteLine(power);
    }
}


Measured memory_bytes: 56712
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
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=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
const int MOD=998244353;
int gcd(int a,int b){
    return (b?gcd(b,a%b):a);
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,x;cin >> n >> x;
    int ans;
    for(int i=0;i<n;i++){
        int a;cin >> a;
        if(!i){
            ans=abs(a-x);
        }
        else{
            ans=gcd(ans,abs(a-x));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int H = sc.nextInt();
			int W = sc.nextInt();
			
			if(H==0&&W==0) break;
			
			for(int i=0;i<H;i++){
				for(int j=0;j<W;j++){
					if(i==0||i==H-1||j==0||j==W-1){
						System.out.print("#");
					}else{
						System.out.print(".");
					}
					
				}
				
				System.out.println("");
			}
			System.out.println("");
		}
	}

}



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

void compute(int n) {
    if (n == 1) return;
    if (n % 2 == 0) {
        cout << " " << 2;
        compute(n/2);
        return;
    }
    for (int i = 3; i * i <= n; i += 2 ) {
        if (n % i == 0) {
            cout << " " << i;
            compute(n/i);
            return;
        }
    }
    cout << " " << n;
    return;
}

int main() {
    int n;
    cin >> n;
    cout << n << ":";
    compute(n);
    cout << endl;
    return 0;
}


Measured memory_bytes: 3120
#include<iostream>
#include<cstring>

using namespace std;

#define IOS ios::sync_with_stdio(0);cin.tie(0);

long long int c[5];

int main(){
	IOS;
	int n;
	while(cin>>n){
		for(int i=0;i<n;i++){
			string a;
			cin>>a;
			if(a[0] == 'M'){
				c[0] = c[0] + 1;
			}
			else if(a[0] == 'A'){
				c[1] = c[1] + 1;
			}
			else if(a[0] == 'R'){
				c[2] = c[2] + 1;
			}
			else if(a[0] == 'C'){
				c[3] = c[3] + 1;
			}
			else if(a[0] == 'H'){
				c[4] = c[4] + 1;
			}
			else{
				continue;
			}
		}
		
		long long int ans = 0;
		for(int i=0;i<5;i++){
			for(int j=i+1;j<5;j++){
				for(int k=j+1;k<5;k++){
					ans = ans + c[i]*c[j]*c[k];
				}
			}
		}
	
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			int N = scan.nextInt();
			int[] P = new int[N];
			
			for(int i = 0;i<N;i++) {
				P[i] =scan.nextInt();
			}
			
			int count = 1;
			int min = P[0];	
			
			
			
			
			
			if(N==1) {
				System.out.println(1);
			}else {
			for(int i = 0;i<N-1;i++) {
				
				if(P[i]>P[i+1]&&min>=P[i+1]){//次の数字が小さくて、最小値以下ならおｋ
					min = P[i+1];//最小値更新
					count+=1;
				}				
			}
			
			
			
			
			System.out.println(count);
			}
			
		}
		
		
	}
		

}


Measured memory_bytes: 81556
// In the name of God 
#include <bits/stdc++.h>

using namespace std ;
 
#define int long long
#define all(v) v.begin() , v.end()

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

const int N = 26 ; 

int n , res [ N ] , cnt [ N ] ; 

int32_t main()                     
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n ;
	memset ( res , 63 , sizeof res ) ; 
	while ( n -- ) {
		string s;
		cin >> s ;
		memset ( cnt , 0 , sizeof cnt ) ;
		for ( auto x : s )
			cnt [ x - 'a' ] ++ ;
		for ( int c = 0 ; c < N ; ++c )
			smin ( res [ c ] , cnt [ c ] ) ; 
	}
	for ( int c = 0 ; c < N ; ++c )
		while ( res [ c ] -- )
			cout << ( char ) ( c + 'a' ) ; 
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
      int a, b, c, temp;
      scanf("%d %d %d",&a,&b,&c);
      if(a>b) { temp=a;  a=b;  b=temp; }
      if(b>c) { temp=b;  b=c;  c=temp; }
      if(a>b) { temp=a;   a=b; b=temp; }
      printf("%d %d %d\n",a,b,c);
      return 0;
}



Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
#define int long long int

signed main()
{
    int a, b, c;
    cin>>a>>b>>c;
    if(c < (a + b)){
        cout<<"No"<<endl;
    }
    else if(4*a*b < (c-a-b)*(c-a-b)){
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 3640
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    ArrayList<Integer> list = new ArrayList<>();
    for (int i = 0; i < 5; i++) {
      list.add(Integer.parseInt(scanner.nextLine()));
    }
    int k = Integer.parseInt(scanner.nextLine());
    for (int i = 0; i < list.size() - 1; i++) {
      for (int j = i + 1; j < list.size(); j++) {
        if ((list.get(i) < list.get(j) && (list.get(j) - list.get(i) > k)) || (list.get(i) - list.get(j) > k)) {
          System.out.println(":(");
          return;
        }
      }
    }
    System.out.println("Yay!");
  }
}

Measured memory_bytes: 21460
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from fractions import gcd
from functools import reduce

N,K,*A = map(int,read().split())

g = reduce(gcd,A)

x = max(A)
bl = (K <= x) and (K % g == 0)
answer = 'POSSIBLE' if bl else 'IMPOSSIBLE'
print(answer)

Measured memory_bytes: 14488
#pragma GCC optimize ("O3")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include <random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ");
//#define double long double

template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
const int MAX = 200060;
const double pi = acos(-1);
const ll INF = 1e16;


void solve() {
	int N; cin >> N;
	vector<int>A(N);
	REP(i, N)cin >> A[i];
	sort(all(A));
	ll ans = 0;
	REP(i, N - 2) {
		FOR(j, i + 1, N - 1) {
			FOR(k, j + 1, N) {
				if (A[i] + A[j] <= A[k])break;
				if (A[i] < A[j] + A[k] && A[j] < A[i] + A[k] && A[k] < A[i] + A[j])ans++;
			}
		}
	}
	print(ans);
}


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

	solve();
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void) {
	char s[5];
	int count = 0;

	cin >> s;

	for (int i = 0; i <= 3; i++) {
		if (s[i] == '+') {
			count++;
		}
		else {
			count--;
		}
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }

int main() {
	IOS;
	int n;
	cin >> n;
	string s;
	cin >> s;
	int q;
	cin >> q;
	vector<int> k(q);
	REP(i, q)cin >> k[i];
	vector<ll> res(q);
	REP(i, q) {
		ll d = 0, m = 0, dm = 0;
		REP(j, n) {
			if (j >= k[i]) {
				if (s[j - k[i]] == 'D') {
					d--;
					dm -= m;
				} else if (s[j - k[i]] == 'M') {
					m--;
				}
			}
			if (s[j] == 'D') {
				d++;
			} else if (s[j] == 'M') {
				m++;
				dm += d;
			} else if (s[j] == 'C') {
				res[i] += dm;
			}
			
		}
	}

	REP(i, q) {
		put(res[i]);
	}

	return 0;
}


Measured memory_bytes: 1948
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

n,m = MAP()
x = LIST()
y = LIST()
xsum = 0
for i in range(n):
    xsum -= (n - 1 - i)* x[i]
    xsum += i * x[i]
    xsum %- mod
ysum = 0
for i in range(m):
    ysum -= (m - 1 - i)* y[i]
    ysum += i * y[i]
    ysum %= mod
print(xsum * ysum % mod)


Measured memory_bytes: 95892
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) std::cout<<arg<<"\n"
#define prin2(arg1,arg2) std::cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) std::memset(arg,n,sizeof(arg))
#define mp(a,b) std::make_pair(a,b)
using std::cin;
typedef long long ll;
typedef std::pair<int,int> pi;
typedef std::pair<int,pi> pipi;
typedef std::vector<int> vi;
typedef std::string str;
const int INF=1e+9;
const ll INFLL=1e+17;
const ll MOD=1e+9+7;
int N,M;
int a[1010],b[1010];
int c[1010];
int d[110];//d[u]は始点から頂点uへの最短距離
bool f[1010];//f[i]は辺iを通ったか否か
std::vector<pipi> g[110];
void add_edge(int from,int to,int cost,int num){
  g[from].push_back(mp(to,mp(cost,num)));
  g[to].push_back(mp(from,mp(cost,num)));  
}
void dijkstra(int s){//始点sからのダイクストラ
  std::priority_queue<pi,std::vector<pi>,std::greater<pi> > q;//pair(コスト、頂点)としてコストの小さい順に並ぶ
  for(int i=0;i<N;i++) d[i]=INF;//初期化
  d[s]=0;
  q.push(mp(0,s));
  while(!q.empty()){
    pi p = q.top();q.pop();
    int w=p.second;//最新の確定した頂点
    if(d[w]<p.first) continue;//取り出した頂点のコストが最短コストより長かったら破棄
    for(int i=0;i<g[w].size();i++){//取り出した頂点と隣接した頂点を調べる
      int t=g[w][i].first,cc=g[w][i].second.first;
      if(d[t]>d[w]+cc){//頂点tまでの暫定最短距離よりwまでの最短距離+w→tのコストが小さければ更新
	d[t]=d[w]+cc;
	q.push(mp(d[t],t));
      }
    }
  }
}
int main(){
  cin>>N>>M;
  rep(i,M){
    cin>>a[i]>>b[i]>>c[i];
    a[i]--;b[i]--;
  }
  rep(i,M){
    add_edge(a[i],b[i],c[i],i);
  }
  rep(i,M) f[i]=false;
  rep(i,N){
    dijkstra(i);
    rep(j,g[i].size()){
      int t=g[i][j].first,cc=g[i][j].second.first,n=g[i][j].second.second;
      if(d[t]>=cc) f[n]=true;
    }
  }
  int res=0;
  rep(i,M) if(!f[i]) res++; 
  prin(res);
  return 0;
}


Measured memory_bytes: 256
package main
import (
	"fmt"
)

func main(){
	var N int
	fmt.Scan(&N)
	A:= make([]int,N)
	ans:= make([]int,N)

	for i:=0;i<N;i++{
		fmt.Scan(&A[i])
	}

	var X int
	for i:=0;i<N;i++{
		switch i%2{
		case 0:
			X+=A[i]
		case 1:
			X-=A[i]
		}
	}

	ans[0] = X

	for i:=1;i<N;i++{
		ans[i] = A[i-1]*2 - ans[i-1]
	}
	for i:=0;i<N;i++{
		if i == N-1{
			fmt.Printf("%d\n",ans[i])
		}else{
			fmt.Printf("%d ",ans[i])
		}
	}
}


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

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
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;
}
template <class T1, class T2>
ostream &operator<<(ostream &s, pair<T1, T2> P)
{
    return s << '<' << P.first << ", " << P.second << '>';
}
template <class T>
ostream &operator<<(ostream &s, vector<T> P)
{
    for (int i = 0; i < P.size(); ++i)
    {
        if (i > 0)
        {
            s << " ";
        }
        s << P[i];
    }
    return s;
}
template <class T>
ostream &operator<<(ostream &s, vector<vector<T>> P)
{
    for (int i = 0; i < P.size(); ++i)
    {
        s << endl
          << P[i];
    }
    return s << endl;
}
template <class T>
ostream &operator<<(ostream &s, set<T> P)
{
    EACH(it, P) { s << "<" << *it << "> "; }
    return s << endl;
}
template <class T1, class T2>
ostream &operator<<(ostream &s, map<T1, T2> P)
{
    EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; }
    return s << endl;
}
template <class T>
void show(vector<T> v)
{
    for (int i = 0; i < v.size(); i++)
    {
        cerr << v[i] << " ";
    }
    cerr << "\n";
}
typedef long long ll;

bool f(string s){
    bool ok=false;
    for (int i = 0; i < s.size()/2; i++)
    {
        if(s[i]!=s[s.size()-1-i]){
            return false;
        }
    }
    return true;
}

signed main()
{
    string s,t,u;
    cin>>s;
    int n=(int)s.size();
    t=s.substr(0,(n-1)/2);
    u=s.substr((n+1)/2,n - (n+1)/2 +1);
    if(f(s) && f(t) && f(u)) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    return 0;
}

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

int main(){
	long long N;
	cin>>N;
	long ans[N+1],function;
	for(int i=1;i<=N;i++)ans[i]=0;
	for(int x=1;x<=100;x++){
		for(int y=1;y<=100;y++){
			for(int z=1;z<=100;z++){
				function = x*x + y*y + z*z + x*y + y*z + z*x ;
				if(function<=N)ans[function]+=1;
			}
		}
	}
	for(int i=1;i<=N;i++){
		cout<<ans[i]<<endl;
	}
}


Measured memory_bytes: 3716