akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
//import java.util.Arrays;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		long happy = (x / 500) * 1000;
		x %= 500;
		happy += (x / 5) * 5;
		System.out.println(happy);
	}
}


Measured memory_bytes: 35720
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;

int main(){
  int n, x;
  while(cin>>n){
    ll ans=1, ans1=1;
    for(int i=0; i<n; ++i){
      cin>>x;
      if(x%2==0){
        ans1*=2;
      }
      ans*=3;
    }
    ans=ans-ans1;
    cout<<ans<<endl;
  }
  return 0;
}



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

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

            int input = int.Parse(Console.ReadLine());
            int h, m, s;

            s = input % 60;
            input = input - s;

            m = ( input / 60 ) % 60;
            

            h = input / 3600;

            Console.WriteLine( h + ":" + m + ":" + s );

        }
    }
}



Measured memory_bytes: 15976
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;

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

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const double PI = acos(-1);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////////////////////

vector<int> X(10),Y(10),x(10),y(10),XX(10),YY(10),xx(10),yy(10),cx(10),cy(10);

void f(int k,int m) {
    rep(i,m) {
        if (k == 0) {
            cy[i] = xx[i];
            cx[i] = -yy[i];
        }
        if (k == 1) {
            cy[i] = -yy[i];
            cx[i] = -xx[i];
        }
        if (k == 2) {
            cy[i] = -xx[i];
            cx[i] = yy[i];
        }
        if (k == 3) {
            cy[i] = yy[i];
            cx[i] = xx[i];
        }
    }
    return;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    while (true) {
        int N; cin >> N;
        if (N == 0) break;
        int M,m; cin >> M;
        rep(i,M) cin >> X[i] >> Y[i];
        rep(i,M) {
            XX[i] = X[i] - X[0];
            YY[i] = Y[i] - Y[0];
        }
        rep(i,N) {
            cin >> m;
            rep(j,m) cin >> x[j] >> y[j];
            if (M != m) continue;
            bool lastok = false;
            rep(j,m) {
                xx[j] = x[j] - x[0];
                yy[j] = y[j] - y[0];
            }
            rep(j,4) {
                f(j,m);
                bool ok = true;
                rep(k,m) {
                    if (XX[k] != cx[k] || YY[k] != cy[k]) ok = false;
                }
                if (ok) lastok = true;
            }
            rep(j,m) {
                xx[j] = x[m-1-j] - x[m-1];
                yy[j] = y[m-1-j] - y[m-1];
            }
            rep(j,4) {
                f(j,m);
                bool ok = true;
                rep(k,m) {
                    if (XX[k] != cx[k] || YY[k] != cy[k]) ok = false;
                }
                if (ok) lastok = true;
            }

            if (lastok) cout << i+1 << endl;
        }
        cout << "+++++" << endl;
    }  
}


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

using namespace std;

//FILE *fi=freopen("1.txt","r",stdin);

int n;
string s;

void process()
{
    int d=0;
    for (int i=1;i<=n;++i)
        d+=(s[i]=='R');
    int dem=0;
    for (int i=1;i<=d;++i)
    {
        dem+=(s[i]=='W');
    }
    cout<<dem;
}

int main()
{
    cin>>n>>s;
    s="1"+s;
    process();
    return 0;
}


Measured memory_bytes: 3932
#include <stdio.h>
int main(void){
    long int N, A[101]={}, sum=0, MAX, WORK=0, i, j;
    scanf("%ld", &N);
    
    for(i=1; i<=N; i++){
        scanf("%ld", &A[i]);
        sum += A[i];
    }
    
    //1日にできる最大の仕事
    MAX = sum / N;
    for(i = MAX; i>=1; i--){
        WORK=0;
        for(j=1; j<=N; j++){
            WORK += A[j];
            if(WORK < i) break;
            WORK -= i;
            if(j == N) break;
        }
        if(j == N) break;
    }
    printf("%ld\n", i);
    return 0;
}



Measured memory_bytes: 2104
#include <iostream>

using namespace std;


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

	int flag = 0;
	for (int i = 0; i <= 25; i++) {
		if (sum < 4 * i) break;
		if (((sum - 4 * i) % 7) == 0) {
			flag = 1;
			break;
		}
	}

	if (flag) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
input = gets.chomp.to_i
num = 1
arr = []
while num <= input do 
    if num % 3 == 0 && num % 5 == 0 then
        arr << "fizzbuzz"
    elsif num % 3 == 0 then
        arr <<  "fizz"
    elsif num % 5 == 0 then
        arr <<  "buzz"
    else
        arr <<  num
    end
        num = num + 1
end
# p arr

arr_only_int = arr.select { |x|
  x.is_a?(Integer)
}
puts arr_only_int.inject(:+)


Measured memory_bytes: 45768
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <stdlib.h>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#define Endl endl
#define rep(N) for(int i=0;i<N;i++)
#define repj(N) for(int j=0;j<N;j++)
#define ll long long 
#define pii pair<int,int>
#define For(I,N) for(int I=0;I<N;I++)
typedef unsigned long long ull;
using namespace std;

bool compare(int a,int b)
{
	return a>b;
}

int main()
{
//	freopen("input.txt","r",stdin);
	int n;
	cin>>n;
	int a[n];
	rep(n)
	{
		scanf("%d",&a[i]);
	}
	int k;
	cin>>k;
	int b[k];
	rep(k)
	{
		scanf("%d",&b[i]);
	}
	sort(a,a+n,compare);
	sort(b,b+k,compare);
	if(n<k)
	{
		cout<<"NO\n";
	}
	else
	{
		int j=0;
		for(int i=0;i<k;i++)
		{
			while(a[j]!=b[i])
			{
				j++;
				if(j==n)
				{
					cout<<"NO\n";
					return 0;
				}
			}
			j++;
		}
		cout<<"YES\n";
	}
	return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int d,r;
		double f;
		d = a / b;
		r = a % b;
		f = (double)a / (double)b;
		String g = String.format("%.5f", f);
		System.out.println(d+" "+r+" "+g);
		
	}

}

Measured memory_bytes: 26524
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
const ll MOD = pow(10, 9) + 7;
int main (void) {
    int N;

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

    int B[N];
    for (int i = 1; i <= N; i++) {
        B[i - 1] = abs((i - 1) - (N - i));
    }

    sort(A, A + N);
    sort(B, B + N);
    bool same = true;
    for (int i = 0; i < N; i++) {
        if (A[i] != B[i]) {
            same = false;
            break;
        }
    }
    ll ans = 0;
    if (!same) {
        ans = 0;
    } else {
        ans = 1;
        for (int i = 0, times = N / 2; i < times; i++) {
            ans = (ans * 2) % MOD;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
import java.util.*;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		long A = sc.nextLong();
		long B = sc.nextLong();
		long min = 100000000;
		long nmin = 0;
		if(A>B)
		{
			min = B;
			nmin = A;
		}
		else
		{
			min = A;
			nmin = B;
		}
		for(long i=1;i<=nmin;i++)
		{
			if(i*min%nmin==0)
			{
				System.out.println(i*min);
				break;
			}
		}
	}
}

Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <map>
#include <numeric>

using namespace std;

bool is_consistent(int N, const map<int, int> &m)
{
	for (int x = 1 - N % 2; x <= N - 1; x += 2) {
		if (m.count(x) == 0) {
			return false;
		}
		if (x == 0) {
			if (m.at(x) != 1) {
				return false;
			}
		}
		else {
			if (m.at(x) != 2) {
				return false;
			}
		}
	}
	return true;
}

const int MOD = 1000 * 1000 * 1000 + 7;

int main()
{
	int N;
	cin >> N;
	map<int, int> m;
	for (int i = 0; i < N; ++i) {
		int A;
		cin >> A;
		++m[A];
	}
	if (is_consistent(N, m)) {
		long long ans = 1;
		for (int i = 0; i < N / 2; ++i) {
			ans = (ans * 2) % MOD;
		}
		cout << ans << endl;
	}
	else {
		cout << 0 << endl;
	}
}


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

int main()
{
  int r,c;
  cin>>r>>c;
  int table[r+1][c+1];
  for (int i = 0; i < r; ++i)
  {
    int sum_r=0;
    for (int j = 0; j < c; ++j)
    {
      cin>>table[i][j];
      sum_r+=table[i][j];
    }
    table[i][c]=sum_r;
  }
  for (int j = 0; j < c+1; ++j)
  {
    int sum_c=0;
    for (int i = 0; i < r; ++i)
    {
      sum_c+=table[i][j];
    }
    table[r][j]=sum_c;
  }
  for (int i = 0; i < r+1; ++i)
  {
    for (int j = 0; j < c+1; ++j)
    {
      cout<<table[i][j];
      if(j!=c) cout<<" ";
    }
    cout<<endl;
  }
}


Measured memory_bytes: 3120
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <math.h>
using namespace std;

int main() {
	
	int n,w;
	
	while(cin>>n){
		for(int i=n-1;i>1;i--){
			w=0;
			for(int j=2;j<224;j++){
				if(i%j==0&&i/j!=1)w=1;
			}
			if(w==0){cout<<i<<" ";break;}
		}
		for(int i=n+1;;i++){
			w=0;
			for(int j=2;j<224;j++){
				if(i%j==0&&i/j!=1)w=1;
			}
			if(w==0){cout<<i<<endl;break;}
		}
	}
}

Measured memory_bytes: 0
#include <cstdio>
#include <utility>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#define REP(i,n) for(int i=0;i<n;i++)
typedef long long ll;
using namespace std;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;

int main() 
{
	int n;
	while(cin >> n && n!=0)
	{
		
		int a[400][400]={};
		int b[4][2]={{-1,0},{0,1},{1,0},{0,-1}};
		int x[200]={};
		int y[200]={};
		x[0]=200;
		y[0]=200;
		a[x[0]][y[0]]=1;
		
		REP(i,n-1)
		{
			int s,t;
			cin >> s >> t;
			x[i+1] = x[s] + b[t][0];
			y[i+1] = y[s] + b[t][1];
			a[x[i+1]][y[i+1]]=1;
		}
		
		int w(0),h(0);
		REP(i,400)
		{
			int tmp(0);
			REP(j,400)if(a[i][j]==1){tmp++;break;}
			if(tmp>0){w++;}
		}
		
		REP(i,400)
		{
			int tmp(0);
			REP(j,400)if(a[j][i]==1){tmp++;break;}
			if(tmp>0){h++;}
		}
		
		cout << w << " " << h << endl;
	}
	return 0;
}

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

int main() {
  ll x;
  cin >> x;
  ll money = 100;
  int i = 0;
  while (money < x) {
    money = money + money / 100;
    i++;
  }
  cout << i << endl;
  return 0;
}

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

const string YES = "Yes";
const string NO = "No";

void solve(long long A, long long B, long long C){
    if(A==B && A!=C) 
        cout << "Yes" << endl;
    else if(A==C && A!=B)
        cout << "Yes" << endl;
    else if(B==C && B!=A)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    solve(A, B, C);
    return 0;
}


Measured memory_bytes: 256
from collections import deque

s = list(input())
d = deque(s)
forward = True
q = int(input())
for i in range(q):
    l = input().split()
    if len(l) == 1:
        forward = not forward
    else:
        pos = int(l[1])
        c = l[2]
        if pos == 1:
            if forward:
                d.appendleft(c)
            else:
                d.append(c)
        else:
            if forward:
                d.append(c)
            else:
                d.appendleft(c)

if forward == False:
    d.reverse()

print("".join(d))


Measured memory_bytes: 9460
S=input()
LS=len(S)
l=[]
n=S[0]
cnt=0

for i,s in enumerate(S):
	if s!=n:
		l.append(cnt if n=='0' else -cnt)
		cnt=1
		n=s
	else:
		cnt+=1
	
	if i==LS-1:
		l.append(cnt if n=='0' else -cnt)

def func(l):
	if len(l)==1:
		return 0
	t=[]
	r=0
	for i in range(len(l)//2):
		a,b=l[2*i],l[2*i+1]
		if a*b<0:
			r+=2*min(abs(a), abs(b))
		t.append(a+b)
	if len(l)%2==1:
		t.append(l[-1])
	r+=func(t)
	return r

print(func(l))

Measured memory_bytes: 4732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

ll a[302][302],b[302],c[302];
bool ch[302];
int main() {
	ll n,m;
	cin>>n>>m;
	ll M=m;
	for(ll i=0;i<n;i++){
		for(ll j=0;j<m;j++){
			ll x;
			cin>>x;
			x--;
			a[i][j]=x;
		}
	}
	ll ans=inf;
	while(M!=0){
	for(ll i=0;i<n;i++){
		ll now=a[i][c[i]];
		while(ch[now]){
			c[i]++;
			now=a[i][c[i]];
		}
		b[now]++;
	}
	ll sum=0;
	for(ll i=0;i<m;i++){
		if(ch[i]){
			continue;
		}
		sum=max(sum,b[i]);
	}
	ans=min(ans,sum);
	for(ll i=0;i<m;i++){
		if(b[i]==sum){
			ch[i]=true;
			M--;
		}
		b[i]=0;
	}
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 896
#include "bits/stdc++.h"
#include<unordered_map>
#pragma warning(disable:4996)
using namespace std;

const int My_Inf=2147483647;
const long long int My_LInf=9223372036854775807;

//  文字列を置換する
std::string Replace(std::string String1, std::string String2, std::string String3)
{
	std::string::size_type  Pos(String1.find(String2));

	while (Pos != std::string::npos)
	{
		String1.replace(Pos, String2.length(), String3);
		Pos = String1.find(String2, Pos + String3.length());
	}

	return String1;
}
int main() {
	while (1) {

		vector<string>froms;
		vector<string>tos;
		set<string>used;
		int N; cin >> N;
		if (!N)break;
		for (int i = 0; i < N; ++i) {
			string f, t; cin >> f >> t;
			froms.push_back(f);
			tos.push_back(t);
		}
		string start, goal; cin >> start >> goal;
		priority_queue<pair<int, string>,vector<pair<int,string>>,greater<pair<int,string>>>que;
		que.push(make_pair(0, start));
		used.emplace(start);
		int ans = -1;
		while (!que.empty()) {
			pair<int, string>atop(que.top());
			que.pop();
			const string st = atop.second;
			if (st == goal) {
				ans = atop.first;
				break;
			}
			if (st.size() >= goal.size())continue;
			
			for (int i = 0; i < N; ++i) {
				string  nst(st);
				bool flag = false;
				nst=Replace(nst, froms[i], tos[i]);
				if (used.find(nst) == used.end()) {
					used.emplace(nst);
					que.push(make_pair(atop.first+1,nst));
				}
			}
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 3316
#include <cstdio>
#include <algorithm>
#include <map>
#define INF 2000000000
#define fi first
#define sec second
using namespace std;
typedef pair<int, int> P;

const int MAX_N = 1 << 17;
int n,m;
int num[200000];
P dat[2*MAX_N-1];

void init(int n_){
	n = 1;
	while(n < n_) n *= 2;
	for(int i = 0; i < 2*n-1; i++){
		dat[i].fi = INF;
		dat[i].sec = -INF;
	}
	for(int i = 0; i < n; i++) dat[i+n-1].fi = i;
}

void update(int k, int a){
	k += n-1;
	dat[k].sec += a;
	while(k > 0){
		k = (k-1)/2;
		if(dat[k*2+1].sec < dat[k*2+2].sec){
			dat[k].sec = dat[k*2+2].sec;
			dat[k].fi = dat[k*2+2].fi;
		} else{
			dat[k].sec = dat[k*2+1].sec;
			dat[k].fi = dat[k*2+1].fi;
		}
	}
}

P query(int a, int b, int k, int l, int r){
	if(r <= a || b <= l) return P(-1,-INF);
	if(a <= l && r <= b) return dat[k];
	else{
		P vl = query(a,b,k*2+1,l,(l+r)/2);
		P vr = query(a,b,k*2+2,(l+r)/2,r);
		if(vl.sec < vr.sec) return vr;
		else return vl;
	}
}

int main(){
	int r,l;
	P s;
	s.fi = 0; s.sec = 0;
	scanf("%d%d%d", &n, &r, &l);
	m = n;
	init(n);
	for(int i = 0; i < m; i++) update(i,INF);
	for(int i = 0; i < r; i++){
		int d,t,x;
		P tmp;
		scanf("%d%d%d", &d, &t, &x);
		d--;
		num[s.fi] += t-s.sec;
		update(d,x);
		tmp = query(0,n,0,0,n);
		s.fi = tmp.fi; s.sec = t;
		//for(int j = 0; j < 2*n-1; j++) printf("%d %d\n", dat[j].fi, dat[j].sec);
		//for(int j = 0; j < n; j++) printf("%d ", num[j]);
		//printf("\n");
	}
	num[s.fi] += l-s.sec;
	int ans = -1;
	for(int i = 0; i < n; i++){
		ans = max(ans,num[i]);
	}
	for(int i = 0; i < n; i++){
		if(ans == num[i]){
			printf("%d\n", i+1);
			break;
		}
	}
}

Measured memory_bytes: 3464
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;
    Func cin2;
    void calc()
    {
        cin = new Scanner();
        cin2 = new Func();
        int n=cin.nextInt();
        long[] a=cin.ArrayLong(3*n,0);
        Array.Sort(a);
        Array.Reverse(a);
        long ans=0;
        for(int i=0;i<n;i++)
        {
          ans+=a[i*2+1];
        }
        Console.WriteLine(ans);
    }


}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Answer
{
    public static void Int2DArrayAns(int[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }//Answer.IntArrayAns(x);
    public static void Char2DArrayAns(char[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }
}

class Func
{
    public long GCDLong(long a, long b)
    {
        while(a!=0)
        {
          long t=a;
          a=b%a;
          b= t;
        }
      
        return b;        
    }
}


Measured memory_bytes: 41676
/*Enter your code here. Read input from STDIN. Print your output to STDOUT*/
#include <bits/stdc++.h>
using namespace std;
#define endl "\n";
#define int long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)

int32_t main()
{
    fastio;
    
    int mod = (int)1e9 + 7;

    int h, w; cin >> h >> w;
    char grid[h+1][w+1];
    int dp[h+1][w+1]; memset(dp, 0, sizeof(dp));

    for(int i=0; i<h+1; i++) grid[i][0] = '#';
    for(int i=0; i<w+1; i++) grid[0][i] = '#';
    grid[0][1] = '.', dp[0][1] = 1;

    for(int i=1; i<=h; i++){
        for(int j=1; j<=w; j++){
            cin >> grid[i][j];

            if(grid[i][j] == '.'){
                //int flag = 0;
                if(grid[i-1][j] == '.' && dp[i-1][j] != 0){
                    dp[i][j] = dp[i-1][j];
                    //flag = 1;
                }
                if(grid[i][j-1] == '.' && dp[i][j-1] != 0){
                    dp[i][j] = (dp[i][j-1] + dp[i][j])%mod;
                }
            }

            //cout << dp[i][j] << " ";
        }
        //cout << endl;
    }

    cout << dp[h][w] << endl;
    return 0;   
}
    

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

void print(vector<string> c) {
  for (size_t i = 0; i < c.size(); ++i) {
    for (size_t j = 0; j < c[i].size(); ++j) {
      cout << c[i][j];
    }
    cout << endl;
  }
}

int count(vector<string> c) {
  int cnt = 0;
  for (size_t i = 0; i < c.size(); ++i) {
    for (size_t j = 0; j < c[i].size(); ++j) {
      if (c[i][j] == '#') {
        ++cnt;
      }
    }
  }
  return cnt;
}

int main() {
  int h, w, K;
  cin >> h >> w >> K;
  vector<string> c(h);
  for (int i = 0; i < h; ++i) {
    cin >> c[i];
  }
  int ans = 0;
  for (int bit = 0; bit < (1 << h); ++bit) {
    vector<string> c2 = c;
    for (int i = 0; i < h; ++i) {
      if (bit & (1 << i)) {
        for (int k = 0; k < w; ++k) {
          c2[i][k] = '*';
        }
      }
    }
    for (int bit2 = 0; bit2 < (1 << w); ++bit2) {
      vector<string> c3 = c2;
      for (int j = 0; j < w; ++j) {
        if (bit2 & (1 << j)) {
          for (int l = 0; l < h; ++l) {
            c3[l][j] = '*';
          }
        }
      }
      // print(c3);
      // cout << endl;
      if (count(c3) == K) {
        ++ans;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3604
#include<iostream>
using namespace std;
typedef long long ll;

int main() {
    ll N, A, B;
    cin >> N >> A >> B;
    ll ans = (B * (N - 1) + A) - (A * (N - 1) + B) + 1;
    if (ans < 0) cout << 0 << endl;
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>



int solve(std::vector<int> s) {
    std::sort(s.begin(), s.end());
    int total = std::accumulate(s.begin(), s.end(), 0);
    if (total % 10 == 0) {
        auto it = s.cbegin();
        auto end = s.cend();
        for (; it != end; ++it) {
            if (*it % 10 != 0) {
                total -= *it;
                break;
            }
        }
        if (it == end) return 0;
    }
    return total;
}

int main() {
    int n;
    std::cin >> n;
    std::vector<int> s;
    for (int i = 0; i != n; ++i) {
        int tmp;
        std::cin >> tmp;
        s.emplace_back(std::move(tmp));
    }
    std::cout << solve(std::move(s)) << std::endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
const int INF = numeric_limits<int>::max();

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

int main()
{
    int n; cin >> n;
    vector<int> s(n);
    rep(i,n) cin >> s[i];
    sort(s.begin(), s.end());
    int sum = 0;
    rep(i,n) sum += s[i];
    if (sum % 10 != 0) {
        cout << sum << endl;
        return 0;
    }
    rep(i,n) {
        if (s[i] % 10 != 0) {
            cout << sum - s[i]<< endl;
            return 0;
        }
    }
    cout << 0 << endl;
    return 0;
}


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

using namespace std;

#define ll long long
#define ull unsigned long long
#define PI acos(-1.0)
#define eps 1e-12
#define fi first
#define se second
#define MEM(a,b) memset((a),(b),sizeof(a))
#define mod(x) ((x)%MOD)
#define pii pair<int,int>
#define wz cout<<"-----"<<endl;
const int INF_INT = 2147483647;
const ll INF_LL = 9223372036854775807LL;
const ull INF_ULL = 18446744073709551615Ull;
const ll P = 92540646808111039LL;

const ll maxn = 1e5 + 10, MOD = 1e9 + 7;
const int Move[4][2] = {-1,0,1,0,0,1,0,-1};
const int Move_[8][2] = {-1,-1,-1,0,-1,1,0,-1,0,1,1,-1,1,0,1,1};

inline int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}


void init() {

}


int a[4][4];
vector<int> aa;
int main(){
//    freopen("C:\\Users\\Administrator\\Desktop\\in.txt","r",stdin);
//    freopen("C:\\Users\\Administrator\\Desktop\\out.txt","w",stdout);
//    ios_base::sync_with_stdio(0);
    init();
	for(int i = 1; i<= 3;i++) {
        for(int j = 1;j <= 3;j ++) {
            cin>>a[i][j];
        }
	}
    for(int k = -1000;k <= 1000;k++) {
        int a2,a3,b1,b2,b3;
        int a1 = k;
        b1 = a[1][1] - k;
        b2 = a[1][2] - k;
        b3 = a[1][3] - k;
        a2 = a[2][1] - b1;
        a3 = a[3][1] - b1;
        bool flg = false;
        if(a[2][2] != a2 + b2) flg = true;
        if(a[2][3] != a2 + b3) flg = true;
        if(a[3][2] != a3 + b2) flg = true;
        if(a[3][3] != a3 + b3) flg = true;
        if(!flg) {
            cout<<"Yes"<<endl;return 0;
        }

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


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <map>


const int mod = 1000000007;
//const int mod = 998244353;
int maximum(int a, int b) { return a < b ? b : a; }
int main() {
	char *S = new char[1000001];
	scanf("%s", S);
	int N = 0;
	for (; S[N] != 0; N++);
	int cnt = 0;
	int p1 = 0;
	auto d = new int[N] {};
	auto b = new int[N] {};
	for (int i = N - 1; i >= 0; i--) {
		if (p1) {
			if (S[i] == '9')continue;
			else S[i]++;
		}
		if (S[i] < '5') {
			b[i] = S[i] - '0';
			d[i] = S[i] - '0';
			cnt += S[i] - '0';
			p1 = 0;
		}
		else if (S[i] == '5') {
			cnt += 5;
			if (i != 0 && S[i - 1] > '4') {
				p1 = 1;
			}
			else {
				p1 = 0;
			}
		}
		else {
			d[i] = '9' - S[i] + 1;
			cnt += '9' - S[i] + 1;
			p1 = 1;
		}
	}
	/*for (int i = 0; i < N; i++)printf("%d", b[i]);
	printf("\n");
	for (int i = 0; i < N; i++)printf("%d", d[i]);
	printf("\n");*/
	if (p1)cnt++;
	printf("%d", cnt);
	return 0;
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define printYes() cout << "Yes" << endl;
#define printNo() cout << "No" << endl;
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  map<string, int> count;
  int N;
  cin >> N;
  rep(i, N)
  {
    string s;
    cin >> s;
    count[s]++;
  }
  int M;
  cin >> M;
  rep(i, M)
  {
    string t;
    cin >> t;
    count[t]--;
  }

  int ans = INT32_MIN;
  for (pair<string, int> p : count)
  {
    ans = max({ans, p.second, 0});
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
from sys import stdin,stdout                           #
import math                                            #
import heapq                                           #
                                                       #
t = 1                                                  #
def aint():                                            #
	return int(input().strip())                        #
def lint():                                            #
	return list(map(int,input().split()))              #
def fint():                                            #
	return list(map(int,stdin.readline().split()))     #
                                                       #	
########################################################
l=[0]*100000
for x in range(1,100):
	for y in range(1,100):
		for z in range(1,100):
			l[x*x+y*y+z*z+x*y+x*z+y*z]+=1
def main():
	n=aint()
	for i in range(1,n+1):
		print(l[i])
	return

#t=int(input())

########################################################
for i in range(t):                                     #
	#print("Case #"+str(i+1)+":",end=" ")		       #
	main()                                             #

Measured memory_bytes: 74888
import sys
from io import StringIO
import unittest
import math

def resolve():
    a, b, h, m = map(int, input().split())

    theta = abs(30 * h + 0.5 * m - 6 * m)

    # if theta > 180:
    #     theta -= 180

    ans = (pow(a,2) + pow(b,2) - 2 * a * b * math.cos(math.radians(theta))) ** 0.5
    print('{:.21g}'.format(ans))

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """3 4 9 0"""
        output = """5.00000000000000000000"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """3 4 10 40"""
        output = """4.56425719433005567605"""
        self.assertIO(input, output)


if __name__ == "__main__":
    # unittest.main()
    resolve()


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

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  cout << (n * (n-1) )/2 + (m* (m-1))/2 << "\n";
return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define MOD 1000000007
#define INF 11234567890
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

LL X, Y;

int main()
{
	in >> X >> Y;
	if (abs(X - Y) <= 1) { out << "Brown" << std::endl; }
	else { out << "Alice" << std::endl; }
	return 0;
}

Measured memory_bytes: 256
#include<cctype>
#include<cstdio>

int main(){
    char ch;
    
    while (1){
        scanf("%c", &ch);
        if(isalpha(ch)){
            if(islower(ch))printf("%c", toupper(ch));
            else printf("%c", tolower(ch));
        
        }
        else printf("%c", ch);
        if(ch == '\n')break;
        
    }
    return 0;
}


Measured memory_bytes: 2692
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };

//BBBBBBBBBBBBBBBBBBBBBBBBBB

int main() {
	int K,X;
	scanf("%d%d", &K,&X);

	for (int i = K-1; i >=0 ; i--) {
		if(X-i>= -1000000 &&X-i<= 1000000)
			printf("%d ", X - i);
	
	
	}
	for (int i = 1; i < K; i++) {
		if (X - i >= -1000000 && X - i <= 1000000)
			printf("%d ", X + i);
		else break;
	}


}





/*         提出前の確認事項

・デバッグ用の関数は＜＜コメント化＞＞しているか？
・すべての＜＜入力例＞＞は試したか？
・＜＜限界値分析＞＞はしたか？
・＜＜出力の改行＞＞の有無は確認したか？
・文字列の＜＜スペル＞＞は確認したか？
　　　　　　　　↓
	 ＜＜提出先＞＞に注意して提出！！
*/

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int maxV = 90010;

 
const int maxN = 1e5+10;

const int INF = 1e9+6;
const int MOD = 1e9+7;


int n,m;
int a[maxN];
int b[maxN];
int c[maxN]; 
ll F[1005][5005];
int main() {
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&a[i],&b[i]);
		int tag = 0;
		for(int j=1;j<=b[i];j++)
		{
			int x;
			scanf("%d",&x);
			x--;
			tag |= (1<<x);
		}
		c[i] = tag;
	}
	int sum = (1<<n);
	for(int i=0;i<=m;i++)
	{
		for(int s=0;s<sum;s++)
		{
			F[i][s] = INF;
			//printf("%d ",F[i][s]);
		}
		//cout<<endl;
	}
	F[0][0] = 0;
	for(int i=1;i<=m;i++)
	{
		for(int s=0;s<sum;s++)
		{
			F[i][s|c[i]] = min(F[i][s|c[i]],F[i-1][s] + a[i]);
			F[i][s] = min(F[i][s],F[i-1][s]);
		}
	}
	int ans = F[m][sum-1];
	if(ans == INF)
		puts("-1");
	else
		cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 39168
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n ; ++i)
#define REP(i,a,b) for(int i=a; i<b; ++i)
typedef long long ll;
//プロトタイプ宣言
int gcd(int , int);


int main(){
  int r;
  cin >> r;
  cout << r*r  << endl;
}








































//以下、ライブラリ
//ユークリッドの互除法

int gcd(int a, int b) {
  return b ? gcd(b, a%b) : a;
}



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

using namespace std;
const int M = 1e5+5;
vector< vector<int> > adj(M);
int memo[M];

int dfs(int n)
{
    int ret=0;
    if(memo[n]!=0) return memo[n];
    if(adj[n].size()==0)
        return 0;
    for(int i=0; i<adj[n].size(); i++)
        ret = max(ret, dfs(adj[n][i])+1);
    memo[n]=ret;
    return memo[n];
}

int main()
{
    int n, m;
    scanf("%d%d", &n, &m);
    for(int i=0, x, y; i<m; i++)
    {
        scanf("%d%d", &x, &y);
        adj[x].push_back(y);
    }
    int ans=0;
    for(int i=0; i<=n; i++)
        ans = max(ans, dfs(i));
    printf("%d", ans);
}


Measured memory_bytes: 8192
use proconio::input;

#[allow(unused_variables)]
fn main() {
    input! {
      n: usize,
      p: [i64; n]
    };

    let mut ans = 0;
    let mut min = p[0];

    for &v in &p {
        if v <= min {
            ans += 1;
            min = v;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 4704
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
 
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 
typedef long long ll;
//No change above here
 
const ll maxi = (2 * 1e5 + 3);
ll mod = (1e9 + 7);
 
//function for power
ll power(ll x, ll n) {
	ll res = 1;
	x %= mod;
	while (n) {
		if (n & 1)
			res = (res * x) % mod;
		x = (x * x) % mod;
		n >>= 1;
	}
	return res;
}
 
ll dir[4][2] = { {1, 0}, {-1, 0}, {0, 1}, {0, -1} };
 
ll p, q;
bool valid(ll i, ll j) { return i >= 1 && i <= p && j >= 1 && j <= q; }
 
//declare needed things here
 
int main()
{
	IOS;
	ll n ,k;
	cin >> n;
	ll mul = 26,count=0;
	string ans;
	while (n > 0)
	{
        --n;

		ll x = n % 26;
		char c = 'a' + x ;
		ans += c;
		n /= 26;
	}
	reverse(ans.begin(), ans.end());
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>

int main(){
		int ans=0;
		char s[4],t[4];
		scanf("%s%s",s,t);
		if(s[0]==t[0])ans++;
		if(s[1]==t[1])ans++;
		if(s[2]==t[2])ans++;
		printf("%d\n",ans);
		return 0;
}


Measured memory_bytes: 128
/* template.cpp(shinobu_menkoi) {{{ */
#include <bits/stdc++.h>
using namespace std;

// clang-format off
#define GET_MACRO(_1, _2, _3, _4, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rep1(n) rep2(_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, n) rep4(i, a, n, 1)
#define rep4(i, a, n, s) for (lint i = (a); i < (lint)(n); i += (s))
#define rrep(...) GET_MACRO(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rrep1(a) rrep2(_, a)
#define rrep2(i, a) rrep3(i, a, 0)
#define rrep3(i, a, n) rrep4(i, a, n, 1)
#define rrep4(i, a, n, s) for (lint i = (a); i >= (lint)(n); i -= (s))
#define each(i, ctn) for (auto &&i : (ctn))

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define all(v) begin(v), end(v)
#define debug(x) cerr << (x) << " (L:" << __LINE__ << ")" << '\n'
#define TEMP_T template <class T>
#define TEMP_TU template <class T, class U>

TEMP_T using vec = vector<T>;
TEMP_T using heap = priority_queue<T>;
TEMP_T using minheap = priority_queue<T, vec<T>, greater<T>>;
using lint = long long;
using ulint = unsigned long long;
using ld = long double;
using vi = vec<int>;
using vvi = vec<vi>;
using vvvi = vec<vvi>;
using pii = pair<int, int>;
using vs = vec<string>;

TEMP_TU ostream &operator<<(ostream &os, const pair<T, U> &p) { return os << p.fi << " " << p.se; }
TEMP_TU istream &operator>>(istream &is, pair<T, U> &p) { return is >> p.fi >> p.se; }

constexpr int INF{1001001001};
constexpr lint LINF{1001001001001001001ll};
constexpr int MOD{(int)1e9 + 7};
constexpr double EPS{1e-9};
const double PI{acos(-1)};
constexpr int dx[]{0, 1, 0, -1, 1, -1, 1, -1}, dy[]{1, 0, -1, 0, 1, -1, -1, 1};

inline bool inside(int y, int x, int h, int w) { return y >= 0 && x >= 0 && y < h && x < w; }
TEMP_T inline bool chmin(T &a, const T &b) { if (a > b) a = b; return a > b; }
TEMP_T inline bool chmax(T &a, const T &b) { if (a < b) a = b; return a < b; }
TEMP_T inline void print(const T &x) { cout << x << '\n'; }
TEMP_T inline void print(const vec<T> &v, string d = "\n") { rep(i, v.size()) cout << v[i] << (i == (lint)(v.size() - 1) ? "\n" : d); }
template <class T = int> inline T in() { T x; cin >> x; return x; }
template <class T = string> vec<T> split(const string &s, char d = ',') {
  vec<T> v; stringstream ss(s); for (string b; getline(ss, b, d); ) {
    stringstream conv(b); T t; conv >> t; v.eb(t); } return v;
}
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } pre__;
// clang-format on
/* }}} */

signed main() {
  string s, t;
  cin >> s;
  rep(i, s.size()) {
    if (i % 2 == 0) {
      t += s[i];
    }
  }
  print(t);
}


Measured memory_bytes: 592
#include <iostream>
#include <vector>
#include <set>

using namespace std;

int main(){
    int D; cin >> D;
    vector<int> c(26, 0);
    for(auto& t : c) cin >> t;
    vector s(D, vector(26, 0));
    for(auto& v : s){
        for(auto& t : v) cin >> t;
    }
    vector<int> last(26, 0);
    vector<set<int>> days(26);
    for(int i=0;i<26;i++){
        days[i].insert(0);
        days[i].insert(D+1);
    }
    vector<int> select(D+1, -1);
    long long score = 0;
    for(int i=1;i<=D;i++){
        int t; cin >> t;
        --t;
        days[t].insert(i);
        select[i] = t;
        score += s[i-1][t];
        last[t] = i;
        for(int j=0;j<26;j++){
            score -= c[j] * (i - last[j]);
        }
    }
    int M; cin >> M;
    for(int i=0;i<M;i++){
        int d, q; cin >> d >> q;
        --q;
        score -= s[d-1][select[d]];
        score += s[d-1][q];
        auto it = days[select[d]].find(d);
        --it;
        auto pre = *it;
        ++it; ++it;
        auto next = *it;
        score += ((d-pre)*(d-pre-1)/2 + (next-d)*(next-d-1)/2) * c[select[d]];
        score -= (next-pre)*(next-pre-1)/2 * c[select[d]];
        days[select[d]].erase(d);
        it = days[q].lower_bound(d);
        next = *it;
        --it;
        pre = *it;
        score -= ((d-pre)*(d-pre-1)/2 + (next-d)*(next-d-1)/2) * c[q];
        score += (next-pre)*(next-pre-1)/2 * c[q];
        days[q].insert(d);
        select[d] = q;
        cout << score << endl;
    }
}

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

int compare(const void *a,const void *b){
    return *(int*)a-*(int*)b;
}

int main(){
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    qsort(a,n,sizeof(int),compare);
    int flg=1;
    for(int i=1;i<n;i++){
        if(a[i]==a[i-1]){
            flg=0;
            break;
        }
    }
    if(flg) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

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

using namespace std;

static const char maru = 'o';
static const char batu = 'x';

int main(){
  string s;
  cin >> s;
  cin.ignore();

  int sum = 0;

  for (int i = 0; i < s.length(); i++){
    if(s[i] == maru){
      sum++;
    }
  }

  // 残り何日？

  if(8 - sum <= 0){
    cout << "YES" << endl;
    return 0;
  }

  int left = 15 - s.length();

  // 残り勝ち数

  int win = 8 - sum;

  if(win <= left){
    cout << "YES" << endl;
    return 0;
  }
  cout << "NO" << endl;
  return 0;
}


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


int main(){
    int n,L;
    cin>>n>>L;
    vector<int> flavours(n);
    vector<int> temp(n);
    int i;
    long sum = 0;
    for(i=0;i<n;i++){
        flavours[i] = L+i;
        sum += flavours[i];
        temp[i] = abs(flavours[i]);
    }
    sort(temp.begin(),temp.end());
    if(flavours[n-1]<=0)
        sum += temp[0];
    else
        sum -= temp[0];
    cout<<sum<<"\n";
    return 0;
}

Measured memory_bytes: 256
from collections import deque

section = raw_input( )
depth = 0
area = 0
depthArr = deque( )
areaArr = deque( )

for i, ground in enumerate( section ):
	if "\\" == ground:
		depth += 1
		depthArr.append( i )
	elif 0 < depth and "/" == ground:
		if len( depthArr ):
			j = depthArr.pop( )
			pool =  i - j
			area += pool

			while len( areaArr ):
				preJ, prePool = areaArr.pop( )
				if j <= preJ:
					pool += prePool
				else:
					areaArr.append( ( preJ, prePool ) )
					break
			areaArr.append( ( j, pool ) )

print( area )
output = []
output.append( len( areaArr ) )
for arr in areaArr:
	output.append( arr[1] )
print( " ".join( map( str, output ) ) )

Measured memory_bytes: 5248
#include<cstdio>
#include<algorithm>
#include<map>
#include<cstring>
#include<cmath>
#include<iostream>
using namespace std;
typedef long long ll;
map<pair<string,string>,ll> cnt;
const int N = 50;
char s[N];
int main(){
    int n; scanf("%d",&n);
    scanf("%s",s);
    for(int i = 0; i < (1 << n); i ++ ){
        string s1 = "",s2 = "";
        for(int j = 0; j < n; j ++ ){
            if(i & (1 << j)) s1 += s[j];
            else s2 += s[j]; 
        }
        cnt[make_pair(s1,s2)]++; 
    }
    ll sum = 0;
    for(int i = 0; i < (1 << n); i ++ ){
        string s1 = "",s2 = "";
        for(int j = n-1; j >= 0; j -- ){
            if(i & (1 << j)) s2 += s[j + n];
            else s1 += s[j + n];
        }
        sum += cnt[make_pair(s1,s2)];
    }
    printf("%lld\n",sum);
}

Measured memory_bytes: 91904
# coding: utf-8

# 条件を満たす数字は、以下のいずれか(a,b,cは2を除く素数)
# typeA: a*b*c
# typeA: a*b^3
# typeA: a^7
# それぞれの場合に、どの素数まで考慮すればよいか
# 素数：2, 3, 5, 7, 11, 13, 17, 19,...
# typeA: 3*5*13<200<3*5*17なので、[3,5,7,11,13]で考えればよい。
# typeB: 3^3*7<200<3^3*11なので、[3,5,7,11]で考えればよい。
# typeC: 200<3^7なので、考えなくてよい。

p = [3,5,7,11,13]
import itertools
import numpy

typeA = list(map(list,list(itertools.combinations(p,3))))
for i in range(len(typeA)):
    typeA[i] = typeA[i][0]*typeA[i][1]*typeA[i][2]

typeB = list(map(list,list(itertools.permutations(p,2))))
for i in range(len(typeB)):
    typeB[i] = typeB[i][0]*typeB[i][1]**3

specialnumbers = typeA + typeB

n = int(input())
print(len(list(filter(lambda x : x <= n, specialnumbers ))))

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

int main()
{
  ll n,i;
  cin>>n;
  vector<ll> A(n+1);
  unordered_map<ll,ll>count;
  for(i=1;i<=n;i++)
  {
    cin>>A[i];
    if(count.find(A[i])!=count.end())
    {
      count[A[i]]++;
    }
    else
    {
      count[A[i]]=1;
    }
  }
  ll sum=0;
  for(auto it=count.begin();it!=count.end();it++)
  {
    ll x=it->second;
    sum+=x*(x-1)/2;
  }
  for(i=1;i<=n;i++)
  {
    cout<<sum-count[A[i]]+1<<endl;
  }
}


Measured memory_bytes: 9160
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end() //使うときはsort(all())という感じで
using ll = long long;
#define PI 3.14159265359

int main(void){
  int n;
  int c=0;
  cin>>n;
  vector<ll> a(n);
  rep(i,n){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  rep(i,n-1){
    if(a[i]==a[i+1]){
      c=1;
      break;
    }
  }
  if(c==1) cout<<"NO"<<endl;
  else cout<<"YES"<<endl;
  return 0;
}


Measured memory_bytes: 1792
var
 i,j,c,x,y,z,n:longint;
begin
 read(n,c);
 for i:=0 to n do
  for j:=0 to n do
   begin
    if i+j<=n then begin
    x:=i*10000;
    y:=j*5000;
    z:=(n-i-j)*1000;
    if x+y+z=c then begin writeln(i,' ',j,' ',(n-i-j));exit;end;
    end;
   end;
 writeln('-1 -1 -1');
end.

Measured memory_bytes: 128
/*
AizuOnline A0533
Title
*/
#include <stdio.h>
// Select Below
#include <stdlib.h>
//#include <string.h>
//#include <float.h>
//#include <math.h>
//#include <limits.h>
//Global data section
int W[20],K[20];

int compare_int(const void *a, const void *b)
{
    return *(int*)b - *(int*)a;
}

main()
{
  int i,s1,s2;

  for(i=0;i<10;i++)
    scanf("%d",&(W[i]));
  for(i=0;i<10;i++)
    scanf("%d",&(K[i]));

  qsort(W,10,sizeof(int),compare_int);
  qsort(K,10,sizeof(int),compare_int);
  printf("%d %d\n",W[0]+W[1]+W[2],K[0]+K[1]+K[2]);

return(0);
}

Measured memory_bytes: 600
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int imos[100010];

signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N, M;
	int L, R;
	cin >> N >> M;
	rep(i, 0, M)
	{
		cin >> L >> R;
		imos[L - 1] ++;
		imos[R]--;
	}

	int ans = 0;
	rep(i, 0, N)
	{
		if (0 < i)
		{
			imos[i] += imos[i - 1];
		}
		if (imos[i] == M)
		{
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define Cr7 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define N   200200
ll n,a[N];
map<ll,ll> mp;
int main()
{
    Cr7
    cin>>n;
    for(ll i=1 ;i <=n ; i++)    cin>>a[i];
    for(ll i=2 ; i<=n ; i++)    mp[a[i]+a[1]-i+1]++;
    ll  need=0,Res=mp[0];
    for(ll i=2 ; i<=n ; i++)
    {
        need--;
        need-=(a[i]-a[i-1]);
        Res+=mp[need];
    }
    cout<<Res<<endl;
    return 0;
}


Measured memory_bytes: 27896
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repv(i,a,b) for(ll i=b-1;i>=a;i--)
#define MAXN 300005
#define endl "\n"

ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;}

int n,l;
vector<int> v;

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int sum=0,minn=INT_MAX;
    cin>>n>>l;
    for(int i=1;i<=n;i++)
    {
        v.pb(l+i-1);
        sum+=(l+i-1);
    }
    // cout<<sum<<endl;
    // for(int i=0;i<v.size();i++) cout<<v[i]<<" ";
    // cout<<endl;
    int p=-1;
    for(int i=0;i<v.size();i++)
    {
        if(abs(v[i])<minn)
        {
            minn=abs(v[i]);
            p=v[i];
        }
    }
    cout<<sum-p<<endl;
}

Measured memory_bytes: 256