akhauriyash/Code-Regression huggingface dataset:
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
using namespace std;

const double ESP = 1E-9;
double x[300];
double y[300];

int main(){
	int n;
	while(cin >> n && n){
		for(int i = 0; i < n; i++){
			char c;
			cin >> x[i];
			cin >> c;
			cin >> y[i];
		}
		int count = 1;
		for(int i = 1; i < n; i++){
			for(int j = 0; j < i; j++){
				double dx = x[j] - x[i];
				double dy = y[j] - y[i];
				double mx = (x[j]+x[i]) / 2;
				double my = (y[j]+y[i]) / 2;
				double dis = sqrt(dx*dx + dy*dy);
				if(dis > 2.0) continue;
				double mdis = dis / 2;
				double dis2 = sqrt(1-mdis*mdis);
				dx /= dis;
				dy /= dis;
				double px[2], py[2];
				px[0] = mx + dis2 * dy;
				px[1] = mx - dis2 * dy;
				py[0] = my - dis2 * dx;
				py[1] = my + dis2 * dx;
				for(int k = 0; k < 2; k++){
					int c = 0;
					for(int l = 0; l < n; l++){
						double dx2 = px[k] - x[l];
						double dy2 = py[k] - y[l];
						double dis3 = dx2 * dx2 + dy2 * dy2;
						if(dis3 < 1 + ESP) c++;
					}
					count = max(count, c);
				}
			}
		}
		cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
using namespace std;

int main(){
  int n;
  long long int ans=0;
  cin >> n;
  vector<long long int> a(n), b(n);
  vector<pair<long long int, int> > pairs(n);

  for(int i=0;i<n;i++){
    cin >> a[i] >> b[i];
    pairs[i]=make_pair(a[i]+b[i],i);
  }
  sort(pairs.begin(), pairs.end());
  int cnt=0, id;
  for(int i=n-1;i>=0;i--){
    id=pairs[i].second;
    if(cnt%2==0)
      ans+=a[id];
    else
      ans-=b[id];
    cnt++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3328
//
//  main.cpp
//  120_A_Favorite_Sound
//
//  Created by tolemy on 2019/08/15.
//  Copyright © 2019 tolemy. All rights reserved.
//

#include <iostream>
#include <algorithm>

using namespace std;

int main(int argc, const char * argv[]) {
    
    
    //a:ジュースの値段
    //b:高橋くんの所持金額
    //c:高橋くんが音を聞きたい回数
    int a, b, c = 0;
    cin >> a >> b >> c;
    
    int count = b / a;
    
    int answer = min(count, c);
    
    cout << answer << endl;
    
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#define MAX 1000000001
using namespace std;
struct Card{
    char suit;
    int value;
};

void merge(Card A[],int left,int mid,int right){
    Card L[mid-left+1],R[right-mid+1];
    for(int i=0;i<mid-left;i++)
        L[i]=A[left+i];
    L[mid-left].value=MAX;
    for(int i=0;i<right-mid;i++)
        R[i]=A[mid+i];
    R[right-mid].value=MAX;
    int L_index=0,R_index=0;
    for(int i=left;i<right;i++){
        if(L[L_index].value<=R[R_index].value){
            A[i]=L[L_index++];
        }
        else
            A[i]=R[R_index++];
    }
}
void mergeSort(Card A[],int left,int right){
    if(left+1<right){
        int mid=(left+right)/2;
        mergeSort(A,left,mid);
        mergeSort(A,mid,right);
        merge(A,left,mid,right);
    }
}
int partition(Card A[],int p,int r){
    int i=p-1;
    Card x=A[r],temp;
    for(int j=p;j<r;j++)
        if(A[j].value<=x.value){
            i++;
            temp=A[i];
            A[i]=A[j];
            A[j]=temp;
        }
    A[r]=A[i+1];
    A[i+1]=x;
    return i+1;
}
void quickSort(Card A[],int p,int r){
    if(p<r){
        int q = partition(A,p,r);
        quickSort(A,p,q-1);
        quickSort(A,q+1,r);
    }
}
int main(){
    int n,j;
    Card A[100000],B[100000];
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>A[i].suit>>A[i].value;
    for(int i=0;i<n;i++)
        B[i]=A[i];
    quickSort(A,0,n-1);
    mergeSort(B,0,n);
    for(j=0;j<n;j++)
        if(A[j].suit!=B[j].suit){
            cout<<"Not stable"<<endl;
            break;
        }
    if(j==n)
        cout<<"Stable"<<endl;
    for(int i=0;i<n;i++)
        cout<<A[i].suit<<' '<<A[i].value<<endl;
    return 0;
}


Measured memory_bytes: 5332
S = gets.chomp
MOD = 10 ** 9 + 7
a = 0
ab = 0
abc = 0
k = 1
S.length.times do |i|
	if S[i] == 'A'
		a = (a + k) % MOD
	elsif S[i] == 'B'
		ab = (ab + a) % MOD
	elsif S[i] == 'C'
		abc = (abc + ab) %  MOD
	else
		abc = (abc * 3 + ab) % MOD
		ab = (ab * 3 + a) % MOD
		a = (a * 3 + k) % MOD
    	k = (k * 3) % MOD
	end
end

puts abc

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int WWW = 0;WWW < (n);WWW++)cerr << v[WWW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

typedef long long ll;
typedef pair<ll,ll> P;

//ａをbで割る
long long mod_div(ll a,ll b){
	if(a % b == 0)return a/b;
	long long tmp = MOD - 2,c = b,ret = 1;
	while(tmp > 0){
		if(tmp & 1){
			ret *= c;ret %= MOD;
		}
		c *= c;c %= MOD;tmp >>= 1;
	}
	return a*ret%MOD;
}

#define MAX_K 333333
vector<long long> kaijo(MAX_K);
long long combination(long long n, long long r){
    if(n < r || n < 0 || r < 0)
        return 0;
	if(kaijo[0] != 1){
		kaijo[0] = 1;
		for(long long i = 1;i < MAX_K;i++)kaijo[i] = (kaijo[i-1] * i) % MOD;
	}
    long long ret = kaijo[n];
	long long tmp = (kaijo[r] * kaijo[n-r]) % MOD;
    return mod_div(ret,tmp);
}

int main(){
	ll n,a,b,k;cin >> n >> a >> b >> k;
	ll ans = 0;
	for(ll i = 0;i <= n;i++){
		if((k-a*i) % b == 0){
			ll j = (k-a*i)/b;
			if(j > n)continue;
			ans += combination(n,i)*combination(n,j)%MOD;
			ans %= MOD;
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 2816
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<int> v;
    vector<int> vk(n,-1);
    for(int i=0;i<n;i++)
    {
        int a;
        cin>>a;
        v.push_back(a);
    }
    int poc=0,k=n-1;
    for(int i=n-1;i>=0;i-=2)
    {
        vk[poc]=v[i];
        if(i)
        vk[k]=v[i-1];
    poc++;
    k--;
    }
    for(int i=0;i<n;i++)
    {
        if(i)
            cout<<" ";
        cout<<vk[i];
    }
    return 0;
}

Measured memory_bytes: 3956
n, k = map(int, input().split( ))
arr = []
for _ in range(n):
  arr.append(int(input()))
a = sorted(arr)
m = 10**9
for i in range(n-k+1):
  ma = a[i+k-1] - a[i]
  m = min(m, ma)
print(m)
  
  

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

int main(){
	string S;
	cin >> S;
	vector<string> v;
	v.push_back(S.substr(0,1));
	S = S.substr(1,S.size()-1);
	while (S.size()>0) {
		string l, r;
		for (int i = 1; i <= S.size(); i++) {
			l = S.substr(0,i);
			r = S.substr(i,S.size()-i);
			if (l != v.back()) {
				v.push_back(l);
				break;
			}
		}
		S = r;
	}
	cout << v.size() << endl;
	return 0;
}


Measured memory_bytes: 12112
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    int n, m;
    cin >> n >> m;
    cout << ( n -1 ) * ( m - 1 ) << endl;
    return 0;
}


Measured memory_bytes: 384
# abc101_a.py
# https://atcoder.jp/contests/abc101/tasks/abc101_a

# A - Eating Symbols Easy /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 100点

# 問題文
# 高橋君は，いつも頭の中に整数を 1つ思い浮かべています．

# はじめ，高橋君が思い浮かべている整数は 0です． 
# これから，高橋君は + または - の記号を，あわせて 4 つ食べようとしています． 
# 高橋君が + を食べると，思い浮かべている整数は 1 大きくなります． 
# 一方，高橋君が - を食べると，思い浮かべている整数は 1小さくなります．

# 高橋君が食べようとしている記号は，文字列 Sで与えられます． S の i 文字目は，高橋君が i番目に食べる記号です．
# すべての記号を食べ終わった後，高橋君が思い浮かべている整数を求めてください．

# 制約
#     Sの長さは 4
#     Sの各文字は + または -

# 入力
# 入力は以下の形式で標準入力から与えられる．
# S

# 出力
# すべての記号を食べ終わった後，高橋君が思い浮かべている整数を出力せよ．

# 入力例 1
# +-++

# 出力例 1
# 2

#     はじめ，高橋君が思い浮かべている整数は 0です．
#     高橋君が食べる 1番目の記号は + です．これを食べた後，高橋君が思い浮かべている整数は 1になります．
#     高橋君が食べる 2番目の記号は - です．これを食べた後，高橋君が思い浮かべている整数は 0になります．
#     高橋君が食べる 3番目の記号は + です．これを食べた後，高橋君が思い浮かべている整数は 1になります．
#     高橋君が食べる 4番目の記号は + です．これを食べた後，高橋君が思い浮かべている整数は 2になります．

# よって，すべての記号を食べ終わった後，高橋君が思い浮かべている整数は 2です．

# 入力例 2
# -+--

# 出力例 2
# -2

# 入力例 3
# ----

# 出力例 3
# -4


def calculation(lines):
    line = lines[0]
    pos = 0
    for i in range(4):
        if line[i] == '+':
            pos += 1
        else:
            pos -= 1
    return [pos]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['+-++']
        lines_export = [2]
    if pattern == 2:
        lines_input = ['-+--']
        lines_export = [-2]
    if pattern == 3:
        lines_input = ['----']
        lines_export = [-4]
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    if len(args) == 1:
        mode = 0
    else:
        mode = int(args[1])
    return mode


# 主処理
def main():
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(1)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')


# 起動処理
if __name__ == '__main__':
    main()


Measured memory_bytes: 9120
/*
Though leaves are many, the root is one;
Through all the lying days of my youth
I swayed my leaves and flowers in the sun,
Now may I wither into the truth.

- William Butler Yeats
*/
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <vector>
#include <set>
#include <cassert>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <sstream>
#include <functional>
#include <iomanip>
#include <bitset>
//#include <windows.h>  //Should be deleted when using AtCoder&POJ
using namespace std;

#define ll long long
#define pii pair<int,int>
#define qi ios::sync_with_stdio(0)
/**==Info==
*Program:
*Problem:
*Date:
*Algorithm:
*Status:*/

bool debug=false;

template<typename T> ostream& operator<<(ostream& o,vector<T> vec){
	o<<"{";
	for(int i=0;i<vec.size();i++){
		o<<vec[i]<<" ";
	}
	o<<"}";
	return o;
}

/*
我自闭了……
以下内容全部瞎写的…… 
*/

int a[200005];
int n,k;

namespace seg{
	pii node[200005*4];
	int n;
	
	void build(int nn){
		n=1;
		while(n<nn){
			n*=2;
		}
		
		fill(node,node+2*n,make_pair(0,1e9));
	}
	
	void update(int pos,int val){
		pos+=n;
		node[pos]=make_pair(val,val);
		while(pos){
			pos>>=1;
			node[pos].first=max(node[pos<<1].first,node[pos<<1|1].first);
			node[pos].second=min(node[pos<<1].second,node[pos<<1|1].second);
		}
	}
	
	int queryM(int l,int r){
		int ans=0;
		l+=n;
		r+=n;
		while(l<=r){
			if(l%2){
				ans=max(ans,node[l].first);
				l++;
			}
			if(!(r%2)){
				ans=max(ans,node[r].first);
				r--;
			}
			l>>=1;
			r>>=1;
		}
		
		return ans;
	}
	
	int queryS(int l,int r){
		int ans=1e9;
		l+=n;
		r+=n;
		while(l<=r){
			if(l%2){
				ans=min(ans,node[l].second);
				l++;
			}
			if(!(r%2)){
				ans=min(ans,node[r].second);
				r--;
			}
			l>>=1;
			r>>=1;
		}
		
		return ans;
	}
};

bool b[200005];
int bp[200005];

int main(int argc,char* argv[]){
	cin>>n>>k;
	
	seg::build(n);
	
	for(int i=0;i<n;i++){
		cin>>a[i];
		
		seg::update(i,a[i]);
		
		if(i==0 || a[i]>a[i-1]){
			b[i]=true;
		}else{
			b[i]=false;
		}
	}
	
	bp[0]=b[0];
	
	for(int i=1;i<n;i++){
		bp[i]=bp[i-1]+b[i];
	}
	
	int ans=1;
	for(int i=1;i<=n-k;i++){
		int secE=i+k-1;
		
		int sec=seg::queryM(i,secE);
		int fir=seg::queryS(i-1,secE-1);
		
//		printf("i=%d,secE=%d,sec=%d,fir=%d,a[sec]=%d,a[i-1]=%d\n",i,secE,sec,fir,a[secE],a[i-1]);
		if(sec==a[secE] && fir==a[i-1]){
			
		}else{
			ans++;
		}
	}
	
//	for(int i=0;i<n;i++){
//		cout<<b[i]<<" "<<bp[i]<<endl;
//	}
	
	bool ok=false;
	bool last=false;
	for(int i=0;i<=n-k;i++){
		if(bp[i+k-1]-bp[i]==k-1){
			if(!last){
//				cout<<"DEL:"<<i<<endl;
				ans--;
				ok=true;	
			}
			last=true;
		}else{
			last=false;
		}
	}
	
	if(ok){
		ans++;
	}
	
	cout<<ans<<endl;
	
	return 0;
}



Measured memory_bytes: 7168
a, b = [int(i) for i in input().split()]
yubin = input()
answer = ''

for i in range(a):
    if yubin[i] == '-':
        answer = 'No'

if yubin[a] != '-':
    answer = 'No'

for i in range(a + 1, a + b + 1):
    if yubin[i] == '-':
        answer = 'No'

if answer == 'No':
    print('No')
else:
    print('Yes')

Measured memory_bytes: 3064
import java.util.Scanner;

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

Measured memory_bytes: 26564
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
using ll = long long;

int main(){
    int n, k, x, y;
    cin >> n >> k >> x >> y;
    cout << min(k, n)*x + (max(0, n-k))*y << endl;
    return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author ei13333
 */

#include <bits/stdc++.h>

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;

class TaskA
{
public:
  void solve(istream &cin, ostream &cout)
  {
    int N;
    cin >> N;
    vector < pair < int, int > > D(N + N);
    for(int i = 0; i < N; i++) {
      cin >> D[i].first;
      D[i].second = 0;
    }
    for(int i = 0; i < N; i++) {
      cin >> D[i + N].first;
      D[i + N].second = 1;
    }
    sort(begin(D), end(D));

    int inA = 0, inB = 0;
    int64 ret = 1;

    for(auto &p : D) {
      if(p.second == 0) {
        if(inB == 0) {
          ++inA;
        } else {
          (ret *= inB--) %= mod;
        }
      } else {
        if(inA == 0) {
          ++inB;
        } else {
          (ret *= inA--) %= mod;
        }
      }
    }

    cout << ret << endl;
  }
};


int main()
{
  TaskA solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return (0);
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", x);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;




int main() {
	ll x;
	cin >> x;

	for (ll b = -1003; b <= 1003; ++b) {
		for (ll a = -1003; a <= 1003; ++a) {
			if (a * a * a * a * a - b * b * b * b * b == x) {
				cout << a << " " << b << endl;
				return 0;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 3512
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>
//#include<bits/stdc++.h>

using namespace std;
long long MOD = 1000000007LL;
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define endl "\n"

int main() {
	int N;
	cin >> N;
	map<string, int> mp;

	int maxValue = 0;
	for (int i = 0; i < N; ++i) {
		string s;
		cin >> s;
		maxValue = max(maxValue, ++mp[s]);
	}

	vector<string> s;
	for (auto i = begin(mp); i != end(mp); ++i) {
		if (maxValue == i->second) {
			s.push_back(i->first);
		}
	}

	sort(begin(s), end(s));

	for (int i = 0; i < s.size(); ++i) {
		cout << s[i] << endl;
	}

	return 0;
}



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


Measured memory_bytes: 2100
n, k, q = map(int, input().split())
list1=[]
n=n+1
ten=[k-q]*(n)

for i in range(q):
    list1.append(int(input()))

for i in range(q):
    ten[list1[i]]=ten[list1[i]] + 1

for i in range(1,n):
    if (ten[i]>0):
        print ("Yes")
    else:
        print ("No")

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

namespace ConsoleApp28 {
    class Program {
        static void Main(string[] args) {
            int N = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(int.Parse).ToArray();

            int ans = 0;

            foreach(var element in a) {
                ans += CountTwoFactor(element);
            }

            Console.WriteLine(ans);

        }

        static int CountTwoFactor(int a_) {
            int cnt = 0;
            while (a_ % 2 == 0) {
                a_ /= 2;
                cnt++;
            }

            return cnt;
        }
    }
}


Measured memory_bytes: 14176
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 10;
int a[maxn], b[maxn];
int main()
{
    int n, k, tot = 0;string s;
    cin >> n >> k >> s;
    int ans = 0;
    for(int i = 0; i < n; i++)
    {
        int j = i;
        for(; j < n; j++)if(s[j] == s[i])continue;else break;
        a[++tot] = j - i;
        b[tot] = s[i] - '0';
        i = j - 1;
        if(b[tot])ans = max(ans, a[tot]);
    }
    if(!k)
    {
        cout<<ans<<endl;
    }
    else
    {
        int l = 1, r = 1;
        int cnt = 0, now = 0;
        while(cnt < k && r <= n)
        {
            if(!b[r])cnt++;
            now += a[r];
            r++;
        }
        if(b[r] && r <= n)now += a[r], r++;
        ans = now;
        while(r <= n)
        {
            if(!b[r])now += a[r], r++;
            if(r <= n && b[r])now += a[r], r++;
            if(b[l])now -= a[l], l++;
            now -= a[l], l++;
            ans = max(ans, now);
        }
        cout<<ans<<endl;
    }
	return 0;
}


Measured memory_bytes: 1280
n = int(input())
l = list(map(int, input().split()))
cash = 1000
stock = 0
c = 0
for i in l:
  #print(cash, stock, i)
  if c==len(l)-1:
    cash+=stock*i
    stock = 0
  elif l[c]==l[c+1]:
    c+=1
    continue
  elif l[c]>l[c+1] and stock>0:
    cash+=stock*l[c]
    stock = 0
  elif l[c]<l[c+1] and stock==0:
    stock = cash//i
    cash = cash-(stock*i)
  c+=1
#print(cash, stock, i)
print(cash)

Measured memory_bytes: 9096
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <stack>
#include <vector>

#define FOR(i,k,n) for(int (i) = (k); (i) < (n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define all(v) begin(v), end(v)
#define debug(x) cerr << #x << ": " << x << endl
#define debug2(x,y) cerr << #x << ": " << x << ", " << #y << ": " << y << endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<i_i, int> p_i;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
template<class T> using vv=vector<vector<T>>;
typedef deque<int> di;
typedef deque<deque<int>> ddi;

int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};
short d[22][22][11] ={};
int ans = 100;

void dfs(i_i p, int t) {
    if(t > 10) return;
    rep(i,4){
        i_i m = p;
        if(d[m.first+dx[i]][m.second+dy[i]][t] == 2) continue; 
        while(1) {
            if(d[m.first+dx[i]][m.second+dy[i]][t] == 0) break;
            if(d[m.first+dx[i]][m.second+dy[i]][t] == 4) {
                ans = min(ans,t); 
                break;
            }
            if(d[m.first+dx[i]][m.second+dy[i]][t] == 2) {
                rep(j,22) {
                    rep(k,22) {
                        d[j][k][t+1] = d[j][k][t];
                    }
                }
                d[m.first+dx[i]][m.second+dy[i]][t+1] = 1;
                dfs(make_pair(m.first,m.second),t+1); 
                break;
            } else {
                m.first += dx[i], m.second += dy[i];
            }
        }
    }
}

int main() {
    while(1) {
        int w,h;
        i_i s;
        ans = 100;
        memset(d,0,sizeof(d)); 
        cin >> w >> h;
        if(w==0) break;
        FOR(j,1,h+1) {
            FOR(i,1,w+1) {
                cin >> d[i][j][1];
                if(d[i][j][1] == 2){s = make_pair(i,j); d[i][j][1] = 0; }
                d[i][j][1] += 1;
            }
        }
        dfs(s,1);
        ans == 100? cout << -1 << endl:cout << ans << endl;
    }
    return 0;
    }

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



int main() {
    int N,M,L;
    cin>>N>>M>>L;
    vector<vector<ll>> world(N,vector<ll>(N,MOD));
    rep(i,M){
        int a,b,c;
        cin>>a>>b>>c;
        --a;--b;
        world.at(a).at(b)=c;
        world.at(b).at(a)=c;
    }

    rep(i,N){
        rep(j,N){
            rep(k,N){
                world.at(j).at(k)=min(world.at(j).at(k),world.at(j).at(i)+world.at(i).at(k));
            }
        }
    }

    vector<vector<ll>> neww(N,vector<ll>(N,MOD));
    rep(i,N){
        rep(j,N){
            if(world.at(i).at(j)<=L){neww.at(i).at(j)=1;}
        }
    }
    rep(i,N){
        rep(j,N){
            rep(k,N){
                neww.at(j).at(k)=min(neww.at(j).at(k),neww.at(j).at(i)+neww.at(i).at(k));
            }
        }
    }

    int Q;
    cin>>Q;
    rep(i,Q){
        int s,t;
        cin>>s>>t;
        --s;--t;
        if(neww.at(s).at(t)>=MOD){cout<<-1<<endl;}
        else{cout<<neww.at(s).at(t)-1<<endl;}
    }
}

Measured memory_bytes: 1920
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		try {
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			String line;
			String[] inputStr;
			long[] num = {0,0,0};
			long tmp, result;
			int i,j;

			while ((line = br.readLine()) != null) {
				inputStr = line.split(" ");
				num[0] = Long.parseLong(inputStr[0]);
				num[1] = Long.parseLong(inputStr[1]);
				num[2] = Long.parseLong(inputStr[2]);

				for(i=0;i<num.length-1;i++) {
					for(j=1;j<num.length;j++) {
						if(num[i] > num[j]) {
							tmp = num[i];
							num[i] = num[j];
							num[j] = tmp;
							continue;
						}
					}
				}
				result = num[0] + num[1];
				System.out.println(result);
			}
		} catch(IOException e) {
		}
	}

}

Measured memory_bytes: 22228
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>

using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n;
  map<int, bool> mp;

  REP(i, n) {
    int a;
    cin >> a;
    if(mp[a] == true) {
      cout << "NO" << endl;
      return 0;
    } else {
      mp[a] = true;
    }
  }

  cout << "YES" << endl;
}


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

int main()
{
    int W,H,x,y,r;
    cin>>W>>H>>x>>y>>r;
    if (0<=(x-r)&&0<=(y-r)&&W>=(x+r)&&H>=(y+r)){
        cout<< "Yes" <<endl;
    } else {
        cout<< "No" <<endl;
    }
}


Measured memory_bytes: 3092
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
const int mod=998244353;
map<string,int>Map;
void operator &= (string &x,string y){
	int len=x.length();
	for(int i=0;i<len;++i)if(y[i]=='0')x[i]='0';
}
int dfs(string s){
	if(!s.length())return 1;
	if(s.length()==1)return s[0]-'0'+1;
	if(Map.count(s))return Map[s];
	int res=dfs(s.substr(1));
	if(s[0]=='1')res=(res<<1)%mod;
	int len=s.length();
	for(int i=1;i<=len;++i){
		string t=s.substr(0,i);
		for(int j=i;j<=len;j+=i){
			if(j+i>len)break;
			t&=s.substr(j,i);
			res=(res+1ll*dfs(t)*dfs(s.substr(j+i)))%mod;
		}
	}
	return Map[s]=res;
}
int main(){
	string s;cin>>s;
	cout<<dfs(s)<<endl;
	return 0;
}


Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using ll = long long;
using ull = unsigned long long;

int main(int argc, char* argv[]) {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);

  /* */
  ll x;
  cin >> x;

  ll s = 2 * (x / 11); x = x % 11;
  if (x > 0 && x <= 6) s++;
  else if (x > 6) s += 2;

  cout << s << endl;
  /* */

  return EXIT_SUCCESS;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

string s;
int rest;
map<string, int> index;    // 変数名に対応する変数番号
vector<int> reference;     // 変数番号に対応するメモリ番号（-1ならばNULL）
vector<int> memory(1, -1); // メモリ番号に対応する確保領域サイズ（-1ならば解放済み）
bool error = false;

int solve(int a, int b)
{
    if(s[a] == '('){
        return solve(a+1, b-1);
    }else if(s[a] == 'm'){
        a += 7;
        int size = 0;
        while(a < b){
            size *= 10;
            size += s[a] - '0';
            ++ a;
        }
        if(size <= rest){
            memory.push_back(size);
            rest -= size;
            return memory.size() - 1;
        }
        return -1;
    }else if(s[a] == 'f'){
        int x = solve(a+5, b-1);
        if(x != -1){
            if(memory[x] == -1){
                error = true;
            }else{
                rest += memory[x];
                memory[x] = -1;
            }
        }
        return -1;
    }else if(s[a] == 'c'){
        int x = solve(a+6, b-1);
        if(x != -1){
            if(memory[x] == -1){
                error = true;
            }else if(memory[x] <= rest){
                rest -= memory[x];
                memory.push_back(memory[x]);
                return memory.size() - 1;
            }
        }
        return -1;
    }else{
        string var;
        while(a <= b && s[a] != '='){
            var += s[a];
            ++ a;
        }
        if(var == "NULL")
            return -1;
        if(index.find(var) == index.end()){
            reference.push_back(0);
            index[var] = reference.size()-1;
        }

        if(s[a] == '='){
            int right = solve(a+1, b);
            reference[index[var]] = right;
        }else{
            return reference[index[var]];
        }
    }
}

int main()
{
    int m;
    cin >> m;
    rest = m;

    while(cin >> s)
        solve(0, s.size()-1);

    if(error){
        cout << "Error" << endl;
        return 0;
    }

    vector<bool> check(memory.size(), false);
    for(unsigned i=0; i<reference.size(); ++i){
        if(reference[i] != -1)
            check[reference[i]] = true;
    }
    for(unsigned i=0; i<memory.size(); ++i){
        if(check[i] && memory[i] != -1)
            rest += memory[i];
    }

    cout << (m - rest) << endl;

    return 0;
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;

#define mem(dp,a)       memset(dp,a,sizeof dp)
#define iOS           	ios_base::sync_with_stdio(false);cin.tie(NULL); 
#define pb(x)           push_back(x)
#define all(c)          c.begin(), c.end()
#define int             long long
#define ff              first
#define ss              second
#define nl              '\n'

vector<int> adj[200005];
int32_t main()
{
	iOS
	int n,m,a,b; cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>a>>b;
		adj[a].pb(b); adj[b].pb(a);
	}
	int dist[n+5];
	int res[n+5];

	mem(dist,-1);
	queue<int> q;
	q.push(1);dist[1]=0;

	while(!q.empty()){
		int node = q.front();
		q.pop();
		for(auto i:adj[node]){
			if(dist[i]==-1){
				q.push(i);dist[i] = dist[node]+1;
				res[i]=node;
			}
			else{
				dist[i] = min(dist[i],dist[node]+1);
				if(dist[i]==dist[node]+1)
					res[i]=node;
			}
		}
	}
	for(int i=1;i<=n;i++){
		if(dist[i]==-1)
			{cout<<"No"; return 0;}
	}
	cout<<"Yes"<<nl; 
	for(int i=2;i<=n;i++){
		cout<<res[i]<<nl;
	}
}



Measured memory_bytes: 16220
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>
#include <new>
#include <typeinfo>

typedef  long long ll;
#define mop 1000000007
#define mop2 998244353
using namespace std;

ll gcd(ll a, ll b) {
    if(a < b) gcd(b, a);
    ll r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

int main() {
    

    ll k;
    cin >> k;
    ll ans = 0;
    for(ll i=1;i<=k;i++){
        for(ll j=1;j<=k;j++){
            for(ll x=1;x<=k;x++){
               ans += gcd(i, gcd(j, x));
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
N,Q = gets.split.map(&:to_i)
S = gets.chomp

a = []
S.each_char.with_index do |s,i|
  if S[i] == 'C' && S[i-1] == 'A'
    a[i] = a[i-1] + 1
  else
    a[i] = a[i-1] || 0
  end
end

Q.times do
  l,r = gets.split.map {|s| s.to_i - 1 }
  puts a[r] - a[l]
end


Measured memory_bytes: 3452
#include<bits/stdc++.h>
#include<utility>
#define ll long long
#define fr first
#define sd second

using namespace std;

struct Node
{
    int data;
    struct Node* left;
    struct Node* right;
    Node(int x) {
        data =x;
        left=NULL;
        right=NULL;
    }
};

#define Node struct Node

int dp[100005];
int calc(int a[], int i)
{
    if(i==0)
        return 0;
    if(i==1)
        return abs(a[1]-a[0]);
  	if(dp[i]!=-1)
      return dp[i];
    return dp[i]=min(abs(a[i]-a[i-1])+calc(a,i-1),abs(a[i]-a[i-2])+calc(a,i-2));
}

int main()
{
    /*freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);*/
    int t=1;
    //cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        int a[n];
        for(int i=0;i<n;i++)
            cin>>a[i];
        memset(dp,-1,sizeof(dp));
        cout<<calc(a,n-1)<<endl;
    }
}











Measured memory_bytes: 8188
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int a = stdIn.nextInt();
		String s = stdIn.next();
		if(a >= 3200) System.out.println(s);
		else System.out.println("red");
		
	}

}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int a,b,c;
multiset<string>s;
int main()
{
    cin>>a>>b>>c;
    for(int i=1;i<=a;i++)s.insert("a");
    for(int i=1;i<=b;i++)s.insert("b");
    for(int i=1;i<=c;i++)s.insert("c");
    while(s.size()>1)
    {
        string ss=(*s.begin())+(*s.rbegin());
        s.erase(s.begin());
        s.erase(--s.end());
        s.insert(ss);
    }
    cout<<(*s.begin());
    return 0;
}


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

#define ll long long

using namespace std;

const int mxn = 2*1e5 + 7;

ll arr[mxn];
ll ans = 0LL;
bool comp(ll &a, ll &b){
    return (a > b);
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   
    int n;
    cin>>n;
    for(int i=0; i<n; i++)
        cin>>arr[i];

    sort(arr, arr+n, comp);

    ans = arr[0];
    for(int i=1; i<n/2; i++){
        ans += 2*arr[i];
    }
    if(n % 2)
        ans += arr[n/2];
    // int i = 1, idx = 0;
    // ans = arr[0];
    // while(i < n-1){
    //     if(idx % 2 == 0)
    //         idx++;
    //     ans += arr[idx];
    //     i++;
    // }
    cout<<ans<<endl;
    return 0;
}

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

int main() {
    int n, x, p, weigh=0;
    int donuts = 0;
    cin >> n >> x;
    vector<int> m;
    for (auto i=0; i<n; i++){
        cin >> p;
        m.push_back(p);
    }
    sort(m.begin(), m.end());

    for(auto itr = m.rbegin(); itr != m.rend(); itr++) {
        weigh += *itr;
        donuts++;
    }

    if(weigh == x){
        cout << donuts << endl;
        return 0;
    }
    while(true){
        weigh += *m.begin();
        if (x < weigh) break;
        donuts++;
    }
    
    cout << donuts << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <bitset>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#else
#define eprintf(...)
#endif

#define TIMESTAMP(x) eprintf("["#x"] Time : %.3lf s.\n", clock()*1.0/CLOCKS_PER_SEC)
#define TIMESTAMPf(x,...) eprintf("[" x "] Time : %.3lf s.\n", __VA_ARGS__, clock()*1.0/CLOCKS_PER_SEC)

using namespace std;

#ifdef LOCAL
static struct __timestamper {
  string what;
  __timestamper(const char* what) : what(what){};
  __timestamper(const string& what) : what(what){};
  ~__timestamper(){
    TIMESTAMPf("%s", what.data());
	}
} __TIMESTAMPER("end");
#else 
struct __timestamper {};
#endif

typedef long long ll;
typedef long double ld;

const int INF = 1000 * 1000 * 1000;

int main() {
#ifdef LOCAL
  freopen("c.in", "r", stdin);
  freopen("c.out", "w", stdout);
#endif

  int x1, y1, x2, y2;
  while (scanf("%d%d%d%d", &x1, &y1, &x2, &y2) == 4) {
    int n;
    scanf("%d", &n);
    vector<pair<int, int>> v(n);
    for (auto &p: v) {
      scanf("%d%d", &p.first, &p.second);
    }
    if (x1 > x2) {
      x1 = -x1;
      x2 = -x2;
      for (auto &p : v) {
        p.first = -p.first;
      }
    }
    if (y1 > y2) {
      y1 = -y1;
      y2 = -y2;
      for (auto &p : v) {
        p.second = -p.second;
      }
    }

    vector<pair<int, int>> v2;
    for (auto p : v) {
      if (x1 <= p.first && p.first <= x2)
        if (y1 <= p.second && p.second <= y2) {
          v2.push_back(p);
        }
    }

    v = v2;

    double ans = (x2 - x1 + y2 - y1) * 100.0;
    sort(v2.begin(), v2.end());
    vector<int> dp(v2.size() + 1, INF);
    for (auto p : v2) {
      *lower_bound(dp.begin(), dp.end(), p.second) = p.second;
    }
    int cnt = 0;
    for (int x : dp) {
      if (x < INF) {
        cnt++;
      }
    }
    ans += (M_PI * 5 - 20) * cnt;
    if (cnt == min(x2 - x1, y2 - y1) + 1) {
      ans += M_PI * 5;
    }
    printf("%.20f\n", ans);
  }

  return 0;
}


Measured memory_bytes: 4208
#include <bits/stdc++.h>
using namespace std;
#define Int int64_t
#define dump(x) cout << (x) << endl
#define fi first
#define se second
Int mod = 1e9+7;
//Int mod = 1e6+3;

int main() {
    pair<double, double> p1, p2;
    cin >> p1.fi >> p1.se >> p2.fi >> p2.se;
    int q;
    cin >> q;
    vector<pair<double, double>> v(q);
    for (int i = 0; i < q; i++) cin >> v[i].fi >> v[i].se;
    for (int i = 0; i < q; i++) {
        if (p1.fi == p2.fi) {
            printf("%.12lf %.12lf\n", p1.fi - (v[i].fi - p1.fi), v[i].se);
        }
        else if (p1.se == p2.se) {
            printf("%.12lf %.12lf\n", v[i].fi, p1.se - (v[i].se - p1.se));
        }
        else {
            pair<double, double> x = v[i];
            double a1 = (p2.se - p1.se) / (p2.fi - p1.fi);
            double b1 = p1.se - a1 * p1.fi;
            double a2 = -1.0 / a1;            
            double b2 = x.se - a2 * x.fi;        
            double rx = (b2 - b1) / (a1 - a2);
            double ry = a1 * rx + b1;
            printf("%.12lf %.12lf\n", (rx - v[i].fi)  * 2.0 + v[i].fi, (ry - v[i].se) * 2.0 + v[i].se);
        }
    }
    return 0;
}


Measured memory_bytes: 3288
// In The Name of ALLAH
// Saiful Islam Tarek
//CSECU

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define _er(i,x,y) for(ll i=x;i<y;i++)
#define _ero(i,x,y) for(ll i=x;i<=y;i++)
#define _inf(i,x) for(ll i=x;;i++)
#define S(n) string n
#define sr(absd) sort(absd.begin(),absd.end())
#define srt(x) sort(arr,arr+x)
#define in(n) scanf("%lld",&n)
#define inn(n,m) scanf("%lld %lld",&n,&m)
#define inr(i) cin>>arr[i]
#define pr(n) cout<<n<<endl
#define par(i) cout<<arr[i]<<" "
#define SL(asd) (int)asd.length()
#define endl '\n'
#define INF 1000000000000
#define MX 1000000
#define pb                  push_back


struct NODE
{
    int u, w;
};
ll parent[MX];
ll dist[MX];
bool vis[MX];

vector<NODE> G[MX];

ll isprime( ll a0)
{
    ll n=a0,a=0;
    if (n==2)
    {
        return 1;
    }
    if (n==1)
    {
        return 0;
    }

    for(ll i=2; i*i<=n; i++)
    {
        if (n%i==0)
        {
            a=1;
            break;
        }
    }
    if (a==1)
    {
        return 0;
    }
    else
    {
        return 1;
    }
}

void _init()
{
    _er(i,0,MX)
    {
        parent[i]=i;
        dist[i]=INF;
    }
}
class cmp
{
public:
    bool operator () (NODE &A, NODE &B)
    {
        if (A.w > B.w)
            return true;
        return false;
    }
};
void FIND(ll node)
{
    if(node==parent[node])
    {
        cout<<node;
        return;
    }
    FIND(parent[node]);
    cout<<" "<<node;
}
void Dijkstra(int s)
{
    priority_queue < NODE, vector <NODE>, cmp > PQ;
    PQ.push({s, 0});
    while(!PQ.empty())
    {
        int u = PQ.top().u;
        int w = PQ.top().w;
        PQ.pop();
        if (vis[u])
            continue;
        vis[u] = 1;
        dist[u] = w;
        int x = G[u].size();
        _er(i,0,x)
        {
            int v = G[u][i].u;
            int z = G[u][i].w;
            if (!vis[v])
            {
                if (w+z < dist[v])
                {
                    dist[v] = w + z;
                    parent[v] = u;
                }
                PQ.push({v, w+z});
            }
        }
    }
}

int main()
{
    fast;
    set<int> s;
    int a,b,c;
    cin>>a>>b>>c;
    s.insert(a);
    s.insert(b);
    s.insert(c);
    int k = s.size();
    if(k==2) cout<<"Yes\n";
    else cout<<"No\n";




    return 0;
}


Measured memory_bytes: 24960
#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
using ll = long long;
using ld =long double;
#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<int,pii> piii;
signed main(){
    int n;cin>>n;
    vector<int>v(n);rep(i,n)cin>>v[i];
    if(n==1){
        if(v[0]%2)cout<<2<<endl;
        else cout<<1<<endl;
        return 0;
    }
    int ans=1;
    int hoge=1;
    rep(i,n){
        ans*=3;
        if(v[i]%2)continue;
        else hoge*=2;
    }
    cout<<ans-hoge<<endl;
}

Measured memory_bytes: 256
s = int(input())
mod = 10**9 + 7

mod = 10**9 + 7
l = 3*10**5 + 3

M = [1]  # i!のmod
mul = 1
for i in range(1, l):
    mul = (mul * i) % mod
    M.append(mul)

def pow(x, y, mod):  # x**y の mod を返す関数
    ans = 1
    while y > 0:
        if y % 2 == 1:
            ans = (ans * x) % mod
        x = (x**2) % mod
        y //= 2
    return ans

def inv(x, mod):  # x の mod での逆元を返す関数
    return pow(x, mod-2, mod)

# print(inv(8,13))

MI = [0] * (l-1) +[inv(M[l-1], mod)]  # i!の逆元
for i in range(l-2, -1, -1):
    MI[i] = MI[i+1] * (i+1) % mod

def C(x, y):  # コンビネーション（組合せ）
    if y < 0 or y > x:
        return 0
    elif x > l:  # O(min(y, x-y))
        y = min(y, x-y)
        ans = 1
        for i in range(x, x-y, -1):
            ans = (ans * i) % mod
        return (ans * MI[y]) % mod
    else:  # O(1)
        ans = M[x]
        ans = (ans * MI[y]) % mod
        return (ans * MI[x-y]) % mod

def P(x, y):  # パーミュテーション（順列）
    if y < 0 or y > x:
        return 0
    elif x > l:  # O(min(y, x-y))
        y = min(y, x-y)
        ans = 1
        for i in range(x, x-y, -1):
            ans = (ans * i) % mod
        return ans % mod
    else:  # O(1)
        ans = M[x]
        return (ans * MI[x-y]) % mod

b = s-3
st = 0
ans = 0
while b >= 0:
    # print(b,st)
    ans = (ans + M[b+st]*MI[b]*MI[st]) % mod
    b -= 3
    st += 1
print(ans)


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

template<typename T>
struct Segtree {
    int n;
    T e;
    vector<T> dat;
    typedef function<T(T a, T b)> Func;
    Func f;

    Segtree(){}
    Segtree(int n_input, Func f_input, T e_input){
        initialize(n_input, f_input, e_input);
    }
    void initialize(int n_input, Func f_input, T e_input){
        f = f_input;
        e = e_input;
        n = 1;
        while(n < n_input) n <<= 1;
        dat.resize(2*n-1, e);
    }

    void update(int k, T a){
        k += n - 1;
        dat[k] = a;
        while(k > 0){
            k = (k - 1)/2;
            dat[k] = f(dat[2*k+1], dat[2*k+2]);
        }
    }

    T get(int k){
        return dat[k+n-1];
    }

    T between(int a, int b){
        return query(a, b+1, 0, 0, n);
    }

    T query(int a, int b, int k, int l, int r){
        if(r<=a || b<=l) return e;
        if(a<=l && r<=b) return dat[k];
        T vl = query(a, b, 2*k+1, l, (l+r)/2);
        T vr = query(a, b, 2*k+2, (l+r)/2, r);
        return f(vl, vr);
    }
};

void fail(){
    cout << -1 << endl;
    exit(0);
}

int main(){
    int N, M;
    string S;
    cin >> N >> M >> S;
    reverse(S.begin(), S.end());

    Segtree<int> st(N+M+1, [](int a, int b){ return max(a, b); }, 0);
    for(int i=0; i<=N; i++) if(S[i] == '0') st.update(i, i);

    vector<int> pos = {0};
    int p = 0;
    while(p < N){
        int p2 = st.between(p, p+M);
        if(p2 == p) fail();
        p = p2;
        pos.push_back(p);
    }

    reverse(pos.begin(), pos.end());
    int sz = pos.size();
    for(int i=0; i<sz-1; i++) cout << pos[i] - pos[i+1] << " \n"[i==sz-2];
    return 0;
}


Measured memory_bytes: 2560
#include<cstdio>
#include<algorithm>
#include<iostream>
using namespace std;
int n,a[101][101];
int dp[2][101],ans;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=2;i++)
	{
		for(int j=1;j<=n;j++)
		{
			scanf("%d",&a[i][j]);
			if(i==1) dp[1][j]+=dp[i][j-1]+a[1][j];
		}		
	} 
	for(int i=n;i>0;i--)
	{
		dp[2][n-i+1]+=dp[2][n-i]+a[2][i];	
		ans=max(dp[1][i]+dp[2][n-i+1],ans);
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)cin>>a[i];
	long long mn=1LL<<62;
	for(int i=-100;i<=100;i++)
	{
		int x=i;
		long long cost=0;
		for(int j=0;j<n;j++)
		{
			cost+=abs(a[j]-x)*abs(a[j]-x);
			
		}
		
		mn=min(mn,cost);
	}
	cout<<mn;
}

Measured memory_bytes: 256
#include <stdio.h>
main(){
  int a,b,k,ans;
  while(scanf("%d %d",&a,&b)!=EOF){
    ans=0;  
    k=a+b;
    do{    
      k/=10;
      ans++;
    } while(k>0);
    printf("%d\n",ans);
  }
  return 0;
}

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

int main() {
  long long A,B,C;
  cin >> A >> B >> C;
  int count = 0;
  int counta = 0;
  int countb = 0;
  
  vector<long long> N(3);
  N = { A, B, C };

  
  if (N.at(0) == N.at(1) && N.at(1) == N.at(2) && N.at(0) % 2 == 0 ){
    cout << -1 << endl;
  }
  else if (N.at(0) == N.at(1) && N.at(1) == N.at(2) && N.at(0) % 2 != 0 ){
    cout << 0 << endl;
  }
  else {
    sort(N.begin(), N.end());
    int D1 = N.at(1) - N.at(0);
    int D2 = N.at(2) - N.at(1);
      
    while (D1 % 2 == 0){
      D1 = D1/2;
      counta = counta + 1;
    }
    
     while (D2 % 2 == 0){
        D2 = D2 / 2;
        countb ++;
    }
    
    if (counta > countb){
      cout << countb << endl;
    }
    else {
      cout << counta << endl;
    }
 }
}  



Measured memory_bytes: 256
import sys

N = int(input())
A = list(map(int, input().split()))

s = []
a = A
i = 0

f = list(map(lambda x: x % 2, A))
if f.count(1):
    print(i)
    sys.exit()

while not s.count(1):
    a = list(map(lambda x: x // 2, a))
    s = list(map(lambda x: x % 2, a))
    i += 1

print(i)

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

using namespace std;

using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

template <typename T>
T gcd(T x, T y) {
    return x ? gcd(y % x, x) : y;
}
template <typename T>
T lcm(T x, T y) {
    return x * y / gcd(x, y);
}

int main() {
    ll n, m, i, j, k;
    cin >> n >> m;
    vector<ll> a(n);
    ll l = 1;
    for(auto &x : a) {
        cin >> x;
        l=lcm(l,x/2);
    }
    ll ret = 0;
    //cout << l << endl;
    for(auto &x:a){
        if(l%x==0){
            cout << 0 << endl;
            return 0;
        }
    }
    cout << (m/l+1)/2 << endl;
    return 0;
}

Measured memory_bytes: 1024
///AJoy Sarker ,CSE JAHANGIRNAGAR UNIVERSITY 48 Batch
#include<bits/stdc++.h>
using namespace std;
#define SORT(c) sort((c).begin(),(c).end());
#define pb push_back
#define MP make_pair
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define pi 3.141592653589793
#define ll long long
#define ull unsigned long long
#define w(x) int x;cin>>x;while(x--)
#define fast ios_base::sync_with_stdio(0)
#define sz size()
typedef unsigned long long UL;
template<typename T>inline T  S(T a)
{
    return a*a;
}
template<class T>inline string tostring(T a)
{
    ostringstream os("");
    os << a;
    return os.str();
}
template<typename T>inline ll tolong(T a)
{
    ll res;
    istringstream os(a);
    os>>res;
    return res;
}
template<typename T>inline T gcd(T a, T b)
{
    if (b == 0)return a;
    else return gcd(b, a % b);
}
template<typename T>inline T bigmod(T a, T b, T m)
{
    if (b == 0)return 1;
    else if (b % 2 == 0)return S(bigmod(a, b / 2, m)) % m;
    else return (a % m*bigmod(a, b - 1, m)) % m;
}
const int inf = (int)1e9 + 5;
const ll linf = (ll)1e16 + 5;
const ll modd = (ll)1e9 + 7;
const int mod = 10000007;
/*#define N 20000009
bool prime[N];
vector<ll> prm;
void seive ()
{

    memset(prime, true, sizeof(prime));

    for( ll i=2; i*i<=N; i++)
    {
        if (prime[i] == true)
        {
            prm.pb(i);
            for (ll j=i*i; j<=N; j += i)
                prime[j] = false;
        }
    }
}*/
void pr (int f)
{
    if(f==1)
        cout<<"YES\n";
    else
        cout<<"NO\n";
}
map<int,int>mp;
multiset<string> st;
multiset<string> :: iterator it;

deque <char> q ;
int vis [1000];
int main()
{
    fast ;
    ll n ;   
   cin >> n;
   cout <<((n)*(n+1))/2<<endl;
}






Measured memory_bytes: 3660