akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

main() {
    int N; cin >> N; double ans = 0;
    rep(i,N){
        double x; string u; cin >> x >> u;
        if(u=="JPY") ans+=x;
        else ans+=(double)x*380000.0;
    }
    cout << setprecision(6) << (double)ans << endl;

    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define SP << " " 
#define LLi long long int

using namespace std;

int imax=2147483647;
long long int llimax=9223372036854775807;

//int型vectorを出力
void PV(vector<int> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

//LLi型vectorを出力
void PVL(vector<LLi> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

int main(){

	LLi n, mon=1000, kab=0, buy=-1, bv, tmp;
	vector<LLi> v, ko;

	cin>> n;
	v.resize(n+1);
	ko.resize(n+1);

	rep(i, n) cin >> v[i];
	v[n]=-1;

	ko[0]=-1;

	for(int i=1;i<=n;i++){
		if(v[i-1]<v[i]) ko[i]=1;
		if(v[i-1]>v[i]) ko[i]=-1;
		if(v[i-1]==v[i]) ko[i]=ko[i-1];
	}

	for(int i=1;i<=n;i++){
		if(ko[i-1]==-1 && ko[i]==1){
			buy=1;
			bv=v[i-1];
			//cout<< i << " " << bv <<endl;
		} 
		if(ko[i-1]==1 && ko[i]==-1 && buy==1){
			//cout<< mon << " " << kab <<endl;
			buy=-1;
			tmp=mon/bv;
			mon-=tmp*bv;
			kab+=tmp;
			//cout<< mon << " " << kab <<endl;

			mon+=kab*v[i-1];
			kab=0;
			//cout<< mon << " " << kab <<endl;
		}
		/*if(i==n-1 && bv<v[i] && buy==1){
			tmp=mon/bv;
			mon-=tmp*bv;
			kab+=tmp;
			mon+=kab*v[i-1];
		}*/
		//cout<< endl;
	}

	cout<< mon << endl;
 
	return 0;
}

Measured memory_bytes: 3508
#12:10
n,k = map(int,input().split())
v = list(map(int,input().split()))
can = []
for i in range(n+1):
  if i == 0:
    a = []
  elif i > k:
    break
  else:
    a.append(v[i-1])
  for j in range(n+1):
    if j == 0:
      b = []
    elif i + j > n or i + j > k:
      break
    else:
      b.append(v[-j])
    c = a + b
    c.sort()
    rest = min(k-i-j,len(c))
    tmp = sum(c)
    for de in range(rest):
      if c[de] < 0:
        tmp -= c[de]
      else:
        break
    can.append(tmp)
    #print(i,j,a,b,tmp)
print(max(can))

Measured memory_bytes: 3064
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int cnt = 0;

        for(int i =a;i<=b;i++){
            String s = String.valueOf(i);
            if(s.charAt(0)==s.charAt(4) && s.charAt(1)==s.charAt(3)){
                cnt++;
            }
        }
        System.out.println(cnt);
    }
}


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

class Main {

	void solve () {

		int a = in.nextInt(), b = in.nextInt(), t = in.nextInt();
		out.println(t/a*b);
		
	}
	
	public static Scanner in = new Scanner(System.in);
	public static PrintWriter out = new PrintWriter(System.out);
	public static void main(String[] args) {
		new Main().solve();
		out.flush();
	}

}

Measured memory_bytes: 21844
fun main(args: Array<String>) {
    abc112a()
}

fun abc112a() {
    val n = readLine()!!.toInt()
    if (n == 1) {
        println("Hello World")
    } else {
        val a = readLine()!!.toInt()
        val b = readLine()!!.toInt()
        println(a + b)
    }
}


Measured memory_bytes: 29824
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <queue>
#include <deque>

using namespace std;

int const N = 1e5+5;

int main(){

int a,i,j;
cin>>a;
for(i=1;i<10;i++){
    for(j=1;j<10;j++){
        if(a==i*j) {
            cout<<"Yes";
            return 0;
        }
    }
}
cout<<"No";
return 0;

}

Measured memory_bytes: 888
#include <stdio.h>

int main(void){
	int i, a, b, c, cnt=0;

	scanf("%d%d%d", &a, &b, &c);

	for(i=a; i<=b; i++){
		if(c%i == 0)
			cnt++;
	}

	printf("%d\n", cnt);

	return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#include<bits/stdc++.h>
#define ld long double
#define ll long long int
#define ull unsigned long long intS
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define in(n) cin>>n>>
#define INF INT_MAX
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define vvc vector<vector<char> >
#define vvs vector<vector<string> >
#define P 1000000007
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;


int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    
    
    int a,b,c,d,l,r;
    
    cin >> a >> b >> c >> d;
    
    l = a+b;
    r = c+d;
    
    if (l>r){
    
    cout << "Left" << endl;
    
    }else if (l == r){
    
    cout << "Balanced" << endl;
    
    }else{
    
    cout << "Right" << endl;
    
    }
    
    
    

    
/////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    if (n == 3 || n == 5 || n == 7) cout << "YES";
    else cout << "NO";
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INFTY=1<<29;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

int main()
{
	vi isp(100004,1); isp[0]=isp[1]=0;
	for(int i=0;i*i<isp.size();i++)
		if(isp[i])
			for(int j=i*i;j<isp.size();j+=i)
				isp[j]=0;
	vi ps;
	rep(i,isp.size()) if(isp[i])
		ps.push_back(i);
	
	for(int m,a,b;cin>>m>>a>>b,m|a|b;){
		vector<pii> cand;
		for(int i=0;ps[i]*ps[i]<=m;i++)
		for(int j=i;ps[i]*ps[j]<=m;j++){
			if(ps[i]*b<ps[j]*a)
				break;
			cand.emplace_back(ps[i],ps[j]);
		}
		int p=-1,q=1;
		rep(i,cand.size())
			if(cand[i].first*cand[i].second>p*q)
				p=cand[i].first,q=cand[i].second;
		cout<<p<<' '<<q<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1832
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n-1){
    int p;
    cin >> p;
    p--;
    a.at(p)++;
  }
  rep(i,n){
    cout << a.at(i) << endl;
  }
}


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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  int i;
  for(i=0;i<n;i++){
    cin >> a.at(i);
  }
  int current = 1;
  int count = 0;
  vector<int> push(n);
  for(i=0;i<n;i++){
     current--;
    if(a.at(current) == 2){
      count++;
      break;
    }
    else if(push.at(current) == 1){
      count = -1;
      break;
    }
    else{
      push.at(current)++;
      count++;
      current = a.at(current);
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 4028
#include <stdio.h>

#define MAXK 100000
#define MAXN 100

int S[MAXK+1]; //0行目が先手
int A[MAXN];

int stones (  int k, int n )
{
	if ( k < 0 ) return 1;
	if ( S[k] != 2 ) return S[k];

	int i;

	for ( i = 0; i < n; i++ ) if ( stones(k-A[i], n) == 0 ) return S[k] = 1;
	return S[k] = 0;

}

int main(void)
{
	int n, k,min,i;

	scanf("%d%d",&n,&k);
	for ( i = 0; i < n; i++ ) scanf("%d", &A[i]);
	for ( i = 0; i <= k; i++ ) S[i] = 2;

	if ( stones(k,n) == 1 ) printf("First\n");
	else printf("Second\n");
	
	return 0;
}


Measured memory_bytes: 5248
#include<iostream>
#include<vector>
#include<stdlib.h>
#include<algorithm>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  vector<long long> b(n);
  long long sum=0;
  for(int i=0;i<n;i++){
    cin >> a[i];
    sum += a[i];
    b[i] = sum;
  }
  long long ans = abs(sum-2*b[0]);
  for(int i=1;i<n-1;i++){
    ans=min(ans,abs(sum-2*b[i]));
  }
  cout << ans << endl;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
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; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    int a; cin>>a;
    cout << a/500*500 << endl;
}





Measured memory_bytes: 3088
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 2
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	k := getNextInt(scanner)
	dp := make([]int64, k+1)
	for i := 1; i <= k; i++ {
		dp[i] = mod(pow(int64(i), n))
	}
	for i := 2; i <= k; i++ {
		prev := i
		d := 1
		for prev > 1 {
			j := i / (d + 1)
			dp[i] = mod(dp[i] - mod(dp[d]*int64(prev-j)))
			d = i / j
			prev = j
		}
	}

	var ans int64
	for i := 1; i <= k; i++ {
		ans = mod(ans + mod(dp[k/i]*int64(i)))
	}
	fmt.Fprintln(writer, ans)
}

func pow(k int64, n int) int64 {
	m := int64(1e9 + 7)
	d := make([]int64, 63)
	d[0] = k
	for i := 0; i < 62; i++ {
		d[i+1] = d[i] * d[i] % m
	}
	var a int64
	a = 1
	for i := 62; i >= 0; i-- {
		if n>>uint(i)%2 == 0 {
			continue
		}
		a = mod(a * d[i])
	}

	return a
}

func mod(a int64) int64 {
	m := int64(1e9 + 7)
	return (a%m + m) % m
}


Measured memory_bytes: 2644
#include<iostream>
#include<cmath>
#define rep(i, n) for (int i = 0; i < (n); i ++)

#define MILL 1000
#define DIFF 6
using namespace std;

int main()
{
  int n;
  cin >> n;
  
  int t, a;
  cin >> t >> a;
  t *= MILL;
  a *= MILL;
  
  int min_index = -1;
  int min_diff = 1000000001;
  int h;
  rep(i, n)
  {
    cin >> h;
    int diff = abs(a - (t - h * DIFF));
    if (diff < min_diff)
    {
      min_diff = diff;
      min_index = i;
    }
  }

  cout << min_index + 1;
  return 0;
}


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

struct Edge {
    int from,to;
    Edge(int f,int t) : from(f), to(t){}
};

using Edges = vector<Edge>;
using Graph = vector<Edges>;

class LowLink {
    public:
        LowLink(int n) : mGraph(n), mOrd(n), mLow(n), mUsed(n,false) {}
        void add_edge(int u, int v){
            mGraph[u].emplace_back(u,v);
            mGraph[v].emplace_back(v,u);
        }
        // e(u,v)が橋　<=> ord[u] < low[v]
        // 頂点vが関節点 <=> ord[u] <= low[v]となるvの子uが存在
        int dfs(int v,int pv,int k){
            mUsed[v] = true;
            mOrd[v] = mLow[v] = k++; // 訪れた順
            bool is_articulation = false;
            int cnt = 0;
            for(Edge nv : mGraph[v]){
                if(!mUsed[nv.to]){ // まだ訪れてない
                    ++cnt;
                    k = dfs(nv.to,v,k);
                    mLow[v] = min(mLow[v], mLow[nv.to]);

                    is_articulation |= ~pv && mOrd[v] <= mLow[nv.to];
                    if(mOrd[v] < mLow[nv.to]) mBridges.emplace_back(minmax(v,nv.to));
                } else if(nv.to != pv){ // 後退辺だったら
                    mLow[v] = min(mLow[v], mOrd[nv.to]);
                }
            }
            is_articulation |= pv == -1 && cnt > 1;
            if(is_articulation) mArticulationPoints.push_back(v);

            return k;
        }

        void Init(){
            int k = 0;
            for(int i = 0; i < mGraph.size(); ++i){
                if(!mUsed[i]) k = dfs(i,k,-1);
            }
        }

        vector<pair<int,int> > GetBridges(){ return mBridges;}
        vector<int> GetArticulationPoints(){ return mArticulationPoints;}

    private:
        Graph mGraph;
        vector<int> mOrd;
        vector<int> mLow;
        vector<bool> mUsed;
        vector<pair<int,int> > mBridges;
        vector<int> mArticulationPoints;
};


int main(){
    int V,E,s,t;
    cin >> V >> E;
    LowLink lowlink(V);
    for(int i = 0; i < E; ++i){
        cin >> s >> t;
        lowlink.add_edge(s,t);
    }
    lowlink.Init();
    auto ans = lowlink.GetBridges();
    sort(ans.begin(),ans.end());
    for(auto e : ans){ cout << e.first << " " << e.second << endl;}
    return 0;
}



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

typedef long long ll;

using namespace std;


int main()
{
    string s;
    cin >> s;
    int score = 0;
    for(int i=0; i<s.length(); i++){
        if(i%2 && s[i] == 'g')
            score++;
        else if(i%2 == 0 && s[i] == 'p')
            score--;
    }
    cout << score << endl;
}


Measured memory_bytes: 512
n = int(input())
a = list(map(int, input().split()))

dp = [[0,-10**9] for _ in range(n+1)]

for i in range(1, n+1):
    dp[i][0] = max(dp[i-1][1]-a[i-1], dp[i-1][0]+a[i-1])
    dp[i][1] = max(dp[i-1][0]-a[i-1], dp[i-1][1]+a[i-1])
print(dp[-1][0])

Measured memory_bytes: 25580
#include <iostream>
#include <string.h>

using namespace std;

int main(){
	int n, r;
	int card[50], shuf[50];
	while(cin >> n >> r){
		if(!n) break;
		for(int i=0;i<n;i++) card[i] = n-i;
		for(int i=0;i<r;i++){
			int p, c; cin >> p >> c;
			int j=0;
			for(j=0;j<c;j++) shuf[j] = card[p-1+j];
			for(j=c;j<c+p-1;j++) shuf[j] = card[j-c];
			for(j=c+p-1;j<n;j++) shuf[j] = card[j];
			memcpy(card,shuf,sizeof(card));
		}
		cout << shuf[0] << endl;
	}
}

Measured memory_bytes: 0
import math
#def gcd(a,b):
#    if b==0:
#        return a
#    else:
#        return gcd(b, a%b)

k = int(input())
ans = 0
for i in range(1,k+1):
    for j in range(1, k+1):
        a = math.gcd(i,j)
        for x in range(1, k+1):
            ans += math.gcd(a,x)

print(ans)

Measured memory_bytes: 9172
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

int m[10] = {0,7,0,9,0,0,0,1,0,3};

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

    LLI k;
    cin >> k;

    if (k % 10 != 1&& k % 10 != 3&& k % 10 != 7&& k % 10 != 9)
    {
        cout << -1;
        return 0;
    }

    LLI t = k;
    int cnt = 0;

    REP(i,10000000)
    {
        if (t == 0)break;
        REP(j, 10)
        {
            if (t % 10 == 7)break;
            else t += k;
        }
        if (t % 10 != 7)
        {
            cout << -1;
            return 0;
        }
        t /= 10;
        cnt++;
    }
    cout << cnt;

    return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
     
    using namespace std;
     
    int main(){
    	int n;
    	cin >> n;
    	int a[n],tmp[n];
    	for(int i=0;i<n;i++){
    		cin >> a[i];
    		tmp[i] = a[i];
    	}
    	sort(tmp,tmp+n);
    	for(int i=0;i<n;i++){
    		if(a[i] <= tmp[(n-1)/2]){
    			cout << tmp[(n+1)/2] << endl;
    		}
    		else{
    		cout << tmp[(n-1)/2] << endl;
    		}
    	}
    	return 0;
    }

Measured memory_bytes: 3712
using System;
using System.Collections.Generic;
using static Assistant.Input;
using static Assistant.Debug;
using System.Linq;
using Assistant;

namespace ABC103C
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = RInt;
            var a = RLongs;

            Console.WriteLine(a.Sum() - N);
        }
    }


}

namespace Assistant
{
    static class Input
    {
        static List<string> line = new List<string>();
        static int index = 0;
        static String RNext()
        {
            if (line.Count <= index) line.AddRange(Console.ReadLine().Split());
            return line[index++];
        }
        public static int RInt => int.Parse(RNext());
        public static long RLong => long.Parse(RNext());
        public static int[] RInts => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static long[] RLongs => Console.ReadLine().Split().Select(long.Parse).ToArray();
        public static string RString => RNext();
        //以下未テスト
        public static int[] RIntsC(int c) => Enumerable.Repeat(0, c).Select(x => int.Parse(RNext())).ToArray();
        public static long[] RLongsC(int c) => Enumerable.Repeat(0, c).Select(x => long.Parse(RNext())).ToArray();
        public static char[][] RMap(int h) => Enumerable.Repeat(0, h).Select(x => Console.ReadLine().ToCharArray()).ToArray();
    }

    static class Debug
    {
        static public void Draw2D<T>(T[,] map, int mode = 1)
        {
#if DEBUG
            int W = map.GetLength(0);
            int H = map.GetLength(1);

            string[,] map2 = new string[W + 1, H + 1];
            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (i == 0 && j == 0) map2[i, j] = 0.ToString();
                    else if (i == 0) map2[i, j] = (j - 1).ToString();
                    else if (j == 0) map2[i, j] = (i - 1).ToString();
                    else map2[i, j] = map[i - 1, j - 1].ToString();
                }
            }

            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (mode == 0) Console.Write(map2[i, j].Last());
                    if (mode == 1) Console.Write(map2[i, j] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
#endif
        }

        public static void Draw1D<T>(T[] array, int mode = 0)
        {
#if DEBUG
            Console.WriteLine(string.Join(" ", array));
#endif
        }
    }
}


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

using Graph = vector<vector<int>>;

int main() {
    int n,m;
    cin >> n >> m;
    Graph g(n);
    for(int i=0;i<m;i++){
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    vector<int> dist(n,-1);
    queue<int> que;

    dist[0] = 0;
    que.push(0);

    while(!que.empty()){
        int v = que.front();
        que.pop();

        for(int nv : g[v]){
            if(dist[nv] != -1)continue;

            dist[nv] = v;
            que.push(nv);
        }
    }
    bool ok = true;
    for(int i=0;i<n;i++){
        if(dist[i] == -1) ok = false;
    }
    if(ok){
        cout << "Yes" << endl;
        for(int i=1;i<n;i++){
            cout << dist[i] + 1 << endl;
        }
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 10272
import sys 
import math
try:
	sys.stdin = open('input.txt', 'r') 
	sys.stdout = open('output.txt', 'w')
except:
	pass
input = sys.stdin.readline
for tt in range(1):
	r = int(input())
	# a,b = map(int,input().split())
	# l = list(map(int,input().split()))
	print(2*math.pi*r)
	

Measured memory_bytes: 61996
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	
	public static int top = 0;
	public static List<Integer> stack = new ArrayList<Integer>();

	public static void push(int x) {
		stack.add(x);
		top ++;
	}
	
	public static int pop() {
		top --;
		return stack.remove(top);
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] inputs = sc.nextLine().split(" ");
		for (String in : inputs) {
			if (in.matches("[0-9]+")) {
				push(Integer.parseInt(in));
			} else {
				int b = pop();
				int a = pop();
				if ("+".equals(in)) 
					push(a+b);
				else if ("-".equals(in)) 
					push(a-b);
				else if ("*".equals(in)) 
					push(a*b);
			}
		}
		sc.close();
		
		System.out.println(pop());
	}

}



Measured memory_bytes: 26392
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseFloat(x::SubString{String}) = parse(Float64, x)
parseFloat(x::Char) = parse(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n=parseInt(readline())
    a=parseMap(split(readline()))
    l=[0 for i in 1:n]
    l[1]=a[1]
    for i in 2:n
        l[i]=l[i-1]+a[i]
    end
    ans=10^10
    for i in 1:n-1
        ans=min(ans,abs(l[i]-(l[end]-l[i])))
    end
    println(ans)
end
main()

Measured memory_bytes: 170836
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
  int n,x;
  cin >> n >> x;
  vector<int> a(n);
  int i;
  for(i = 0;i < n;++i){
    cin >> a.at(i);
  }
 
  sort(a.begin(),a.end());
  int modea = 0;
  while(x > 0){
    x -= a.at(modea);
    ++modea;
    if(modea == n){break;}
  }
  if(modea == n){
    if(x == 0){
      cout << n << endl;
      return 0;
    }else{
      cout << --n <<endl;
      return 0;
    }
  }
  if(x == 0){
    cout << modea << endl;
  }else{
    cout << modea-1 << endl;
  }
  return 0;
}


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

int main(){
  int k;
  scanf("%d",&k);
  queue<ll> a;
  for(int i = 1; i <= 9; i++){
    a.push(i);
  }
  ll ans;
  for(int i = 0; i < k; i++){
    ans = a.front();
    a.pop();
    if(ans % 10 != 0){
      a.push(ans*10 + ans%10 -1);
    }
    a.push(ans*10+ ans%10);
    if(ans % 10 != 9){
      a.push(ans*10 + ans%10 +1);
    }
  }
  cout << ans << endl;
}
      
    

Measured memory_bytes: 1792
def main():
    S = input()
    stack = list()
    cnt = 0
    for c in S:
        if len(stack) == 0:
            stack.append(c)
        else:
            if stack[-1] != c:
                stack.pop()
                cnt += 2
            else:
                stack.append(c)
    print(cnt)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3956
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<stdio.h>
int main() {
	int *P, i, j, k, jj, n, p[10001] = {0};
	for (i = 2; i <= 10000; i++) {
		if(p[i]==0){
			for (j = 2 ;i*j <= 10000; j++) {
				p[i*j] = 1;
			}
		}
		
	}
	while (1) {
		scanf("%d", &n);
		if (n == 0) break;		
		for (i = n; i >= 2; --i) {
			if (p[i] == 0 && p[i - 2] == 0) {
				printf("%d %d\n", i - 2, i);
				break;
			}
		}
		/*
		k = 2;
		P = (int*)calloc(n, sizeof(int));
		for (i = 0; i <= n - k; i++) {
			*(P + i) = i + 2;
		}
		for (i = 0; *(P + i) <= (int)sqrt((double)n); i++) {
			for (j = i + 1; j < n - k; j++) {
				if (*(P + j) % *(P + i) == 0) {
					for (jj = j; jj < n - k; jj++) *(P + jj) = *(P + jj + 1);
					k++;
				}
			}
		}

		for (i = n; i > 0; --i) {
			if (*(P + i) - *(P + i - 1) == 2) {
				printf("%d %d\n", *(P + i - 1), *(P + i));
				break;
			}
		}
		free(P);
		*/
	}

	return 0;
}

Measured memory_bytes: 648
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>
#include <cassert>
#include <bitset>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define EL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	int n;
	std::cin >> n;
	int min = 64;
	rep(i,n) {
		int x;
		std::cin >> x;
		min=std::min(min,(int)__builtin_ctz(x));
	}
	print(min);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;
#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int> >, rb_tree_tag,tree_order_statistics_node_update>
#define standardVar ll n,m,i,j,k,num,num1,num2,flag=0
#define nn <<"\n"
#define __ <<" "<<
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define ittr(x,v) for(auto x=v.begin();x!=v.end();x++)
#define itr(x,n) for(x=0;x<n;x++)
#define itrab(x,a,b) for(x=a;x<b;x++)
#define itpr(v) ittr(x,v)cout<<*x<<" "; cout nn
#define itppr(v) ittr(x,v)cout<<(*x).ff<<" "<<(*x).ss<<"  "; cout nn
#define size(x) (ll)x.size()
#define pi 3.14159265359
#define dTor(x) ((x)*pi)/180.0
#define INF 1000000100;

typedef long long int ll;       //TYPEDEFS
typedef long double ld;
typedef vector<ll> vl;
typedef map<ll,ll> ml;
typedef set<ll> sl;
typedef string str;
typedef pair<ll, ll> pl;
typedef vector< pl > vpl;
typedef map<pl,ll> mpl;
typedef set< pl > spl;
typedef vector<str> vst;
typedef vector<vl> vvl;

const ll M=1000000007;          //COMMON MODULO PRIMES
const ll N=998244353;

ll power(ll x, ll y, ll p){     //MODULAR EXPONENTIATION
    ll res=1;
    x=x%p;
    if(x==0)
        return 0;
    while(y>0){
        if(y&1)
            res=(res*x)%p;
        y=y>>1;
        x=(x*x)%p;
    }
    return res;
}
ll inv(ll x, ll m){             //FERMAT INVERSE
    return power(x,m-2,m);
}
struct comp{                    //COMPARISON ON PAIRS
    template<typename T>        
    bool operator()(const T &a, const T &b){
        if (a.ff==b.ff)
            return (a.ss<b.ss);
        else
            return (a.ff<b.ff);
    }
};
bool mod(const pair<ll,ll> &a, const pair<ll,ll> &b){   //COMPARATOR FOR PAIRS (SORTING)
    if(a.ff!=b.ff)
        return (a.ff>b.ff);
    else
        return (a.ss>b.ss);
}
vector<bool> pr(1000000+1,1);
void sieve(ll mn, ll mx){       //SIEVE OF ERATOSTHENES
    for(ll i=mn;i*i<=mx;i++)
        if(pr[i-mn]==1)
            for(ll j=i*i;j<=mx;j+=i)
                pr[j-mn]=0;
}
bool isValid(ll i, ll j, ll n, ll m){   //CHECKS FOR OVERFLOW
    if(i>=0&&i<n&&j>=0&&j<m){
        return true;
    }
    return false;
}

//MAIN FUNCTION STARTS HERE

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    standardVar;
    cin>>n;
    vl v;
    ll mx=-1;
    itr(i,n){
        cin>>num;
        v.pb(num);
        mx=max(num,mx);
    }
    sort(all(v));
    vl a(mx+1,0);
    itr(i,n){
        //cout<<v[i] nn;
        for(j=v[i];j<=mx;j+=v[i]){
            //cout<<j<<" ";
            a[j]++;
        }
        //cout nn;
    }
    ll c=0;
    //itpr(a);
    itr(i,n){
        if(a[v[i]]==1){
            c++;
        }
    }
    cout<<c nn;
    return 0;
}

Measured memory_bytes: 12728
// 2012/01/10 Tazoe

#include <iostream>
#include <deque>
#include <algorithm>
using namespace std;

int main()
{
	while(true){

	int d;
	cin >> d;

	if(d==0)
		break;

	int n;
	cin >> n;

	int m;
	cin >> m;

	deque<int> S;
	S.push_back(0);
	S.push_back(d);

	for(int i=0; i<n-1; i++){
		int D;
		cin >> D;
		S.push_back(D);
	}

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

	int sum = 0;
	for(int i=0; i<m; i++){
		int K;
		cin >> K;

		deque<int>::iterator it = S.begin();
		while(it!=S.end()){
			if(*it>K)
				break;
			it++;
		}

		int D1 = *it-K;
		it--;
		int D2 = K-*it;
		if(D1<D2)
			sum += D1;
		else
			sum += D2;
	}

	cout << sum << endl;

	}

	return 0;
}

Measured memory_bytes: 1316
#include <bits/stdc++.h>
using namespace std;
const int nmax = 8;
bool graph[nmax][nmax];

// 再帰する際に持たせたいのはどこまで探索したか(visited)とどこに始点があるか
int dfs(int v, int N, bool visited[nmax]) {
    bool all_visited = true;

    // ここが頂点を探索したかどうかを毎回チェックするところ
    for(int i = 0; i < N; i++) {
        if(visited[i] == false) {
            all_visited = false;
        }
    }

    // 全部の探索に成功したらあとは順番に1を加算していくだけ、その最初の1をここで宣言していく
    if(all_visited) {
        return 1;
    }

    int ret = 0;

    for(int i = 0; i < N; ++i) {
        if(graph[v][i] == false) continue;
        if(visited[i]) continue;

        visited[i] = true;
        ret += dfs(i, N, visited);
        visited[i] = false;
    }

    return ret;
}

int main() {
    int N, M;
    cin >> N >> M;
    for(int i = 0; i < M; i++) {
        int A, B;
        cin >> A >> B;
        graph[A-1][B-1] = graph[B-1][A-1] = true;   // 隣接行列を作るとはこういうこと
    }

    bool visited[nmax];
    for(int i = 0; i < N; ++i) {
        visited[i] = false;
    }

    visited[0] = true;
    cout << dfs(0, N, visited) << endl;
    return 0;
}

Measured memory_bytes: 256
s = sorted(map(str, input()))
t = sorted(map(str, input()))
if len(set(s)) == len(set(t)) == 1:
    if len(s) < len(t):
        print('Yes')
    else:
        print('No')
else:
    if ord(s[0]) < ord(t[-1]):
        print('Yes')
    else:
        print('No')


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

using namespace std;


class combination {
public:

//Nの最大値がわかれば代入する
	combination( long long int combinationThreshold = 1e7 ) {
		( *this ).combinationThreshold = combinationThreshold + 2;
	}

	//a^p % mod
	long long int powmod( long long int A, long long int P, long long int M = LLONG_MAX ) {
		long long int ans = 1;
		long long int mul = A;
		for( ; P > 0; P >>= 1, mul = ( mul*mul ) % M ) {
			if( ( P & 1 ) == 1 ) ans = ( ans*mul ) % M;
		}
		return ans;
	}

	//nCk mod m
	long long int cb( long long int N, long long int K, long long int M = LLONG_MAX ) {
		if( N < combinationThreshold ) {// 事前計算O(N)、答えるのはO(1)
			if( inv.size() == 0 ) {
				inv = vector<long long int>( combinationThreshold );
				inv[1] = 1;
				for( long long int i = 2; i < combinationThreshold; i++ ) {
					inv[i] = M - ( M / i )*inv[M%i] % M;
				}
				fact = vector<long long int>( combinationThreshold );
				fact[0] = 1;
				revFact = vector<long long int>
					( combinationThreshold );
				revFact[0] = 1;
				for( long long int i = 1; i < combinationThreshold; i++ ) {
					fact[i] = ( fact[i - 1] * i ) % M;
					revFact[i] = ( revFact[i - 1] * inv[i] ) % M;
				}
			}
			return ( ( ( fact[N] * revFact[K] ) % M )*revFact[N - K] ) % M;
		} else {
			return cbOnce( N, K, M );
		}
	}

	//一回だけなら最速 O(K + log(M))
	long long int cbOnce( long long int N, long long int K, long long int M = LLONG_MAX ) {
		if( K > N / 2 ) return cb( N, N - K, M );
		long long int ans = 1;
		long long int div = 1;
		for( long long int i = 0; i < K; i++ ) {
			ans *= N - i;
			ans %= M;
			div *= i + 1;
			div %= M;
		}
		ans *= powmod( div, M - 2, M );
		return ans%M;
	}

private:
	vector<vector<long long int>>C;//3000以下の答え
	vector<long long int>fact;//階乗
	vector<long long int>revFact;//階乗の逆元
	vector<long long int>inv;//mod pでの逆元

	long long int combinationThreshold;//Nの最大値がわかれば入れる。
};



#define mod  1000000007LL

int main() {
	long long int N;
	cin >> N;
	vector<long long int>D( N + 1, -1 );
	pair<long long int, long long int>memo;
	for( long long int i = 0; i <= N; i++ ) {
		long long int X;
		cin >> X;
		if( D[X - 1] != -1 ) {
			memo.first = D[X - 1];
			memo.second = i;
			break;
		} else {
			D[X - 1] = i;
		}
	}
	combination cb( N + 20 );
	for( size_t i = 1; i <= N + 1; i++ ) {
		long long int ans = cb.cb( N + 1, i, mod );
		//cout << N - 1 - ( memo.second - memo.first - 1 ) << " " << i - 1 << endl;
		if( N - memo.second + memo.first >= i - 1 ) {
			ans -= cb.cb( N - memo.second + memo.first, i - 1, mod );
		}
		ans += mod * 10;
		ans %= mod;
		cout << ans << endl;
	}
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); ++i)
#define FOR(i, s, n) for(int i=(int)(s); i<(int)(n); ++i)
#define ALL(n) (n).begin(), (n).end()
#define pb push_back

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> mat;

const ll MAX_V = 100000;
const ll INF = 1e9;
const ll MOD = 998244353;

class Dinic{
    // to:頂点インデックス, cap:容量, rev:逆辺を表すGのインデックス
    struct edge{int to, cap, rev;};
    void bfs(int s);
    int dfs(int v, int t, int f);
    public:
        // G:隣接リスト, level:sからの距離, iter:調べたかどうかのフラグ
        vector< vector<edge> > G;
        int level[MAX_V];
        int iter[MAX_V];
        Dinic(mat g);
        int solve(int s, int t);
};

Dinic::Dinic(mat g){
    G.resize(MAX_V);
    // g : 隣接行列, Dinic.G : 隣接リスト
    REP(from, g.size()) REP(to, g.size()){
        if (g[from][to] > 0){
            G[from].pb((edge){to, g[from][to], G[to].size()});
            G[to].pb((edge){from, 0, G[from].size()-1});
        }
    }
}

// フローを流せる全ての頂点について，頂点sからの最短距離をBFSで計算する
void Dinic::bfs(int s){
    memset(level, -1, sizeof(level));
    queue<int> q;
    level[s] = 0;
    q.push(s);
    while(!q.empty()){
        int v = q.front();
        q.pop();
        REP(i, G[v].size()){
            edge &e = G[v][i];
            if(e.cap > 0 && level[e.to] < 0){
                level[e.to] = level[v] + 1;
                q.push(e.to);
            }
        }
    }
}

int Dinic::dfs(int v, int t, int f){
    if (v == t) return f;
    for (int i=iter[v]; i<G[v].size(); i++){
        edge &e = G[v][i];
        if (e.cap > 0 && level[v] < level[e.to]){
            int d = dfs(e.to, t, min(f, e.cap));
            if (d > 0){
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

int Dinic::solve(int s, int t){
    // cout << G[0][0].cap << endl;
    int flow = 0;
    while(true){
        bfs(s);
        if (level[t] < 0) return flow;
        memset(iter, 0, sizeof(iter));
        int f;
        while ((f = dfs(s, t, INF)) > 0){
            flow += f;
        }
    }
}

int main(){
    int V, E; cin >> V >> E;
    mat g_mat(V, vi(V, 0));
    REP(i, E){
        int u, v, c;
        cin >> u >> v >> c;
        g_mat[u][v] = c;
    }
    Dinic dn(g_mat);
    int ans = dn.solve(0, V-1);
    cout << ans << endl;
}


Measured memory_bytes: 6060
#include<bits/stdc++.h>
#include<stack>
#include<vector>
#include<string>
#define int long long
using namespace std;
main()
{
	//freopen("input.txt","rt",stdin);
	int n,x;
	cin>>n>>x;
	int arr[n];
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	int d = 0;
	int s =0;
	int p =0;
	int b[n+1];
	b[0] = 0;
	for(int i=0;i<n;i++)
	{
		b[i+1] = b[i] + arr[i];
	}
	for(int i=0;i<=n;i++)
	{
		if(b[i]<=x)
		{
			p++;
		}
	}
	cout<<p<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main ()
{
	int k,x,i,min,max;
	scanf("%i%i",&k,&x);
	min=x-(k-1);
	max=x+(k-1);
	for(i=min;i<=max;i++)
	{
		printf("%i ",i);
	}
	return 0;
}



Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <functional>
#define rep(i, n) for(int i = 0; i < n; i++)
#define ll long long
using namespace std;


int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    int debt = 100000,   n;
    cin >> n;
    rep(i, n) {
        debt *= 1.05;
        if (debt % 1000 > 0) {
            debt = (debt / 1000 + 1) * 1000;
        }
    }
    cout << debt << "\n";
	return 0;
}


Measured memory_bytes: 3176
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<sstream>
#include<utility>
#include<map>
#include<ctime>
#include<cstdio>
#include<cassert>
#include<functional>




using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;
typedef pair<double, double> pdd;

#define show(x) cerr << x
#define debug(x) show(#x << ": " << (x) << endl)

const long double PI = 3.14159265358979323846;
const long double eps = 1e-5;
const int INF = numeric_limits<int>::max();
const ll LINF = numeric_limits<ll>::max();
const ll mod = 998244353;


ll power(ll x, ll n) {
    ll res = 1;
    while (n) {
        if (n & 1) {
            res = (res * x) % mod;
        }
        x = (x * x) % mod;
        n /= 2;
    }
    return res;
}


void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    int N = 100000;
    vector<ll> d(2 * N, 0), dd(2 * N, 0);
    d[N] = 1;
    for (int i = 0; i < n; ++i) {
        dd.assign(2 * N, 0);
        for (int j = 0; j < d.size(); ++j) {
            int k = j + a[i];
            if (k < d.size()) {
                dd[k] = (dd[k] + 2 * d[j]) % mod;
            }
            k = j - a[i];
            if (k >= 0) {
                dd[k] = (dd[k] + d[j]) % mod;
            }
        }
        swap(d, dd);
    }
    ll res = power(3, n);
    for (int i = 0; i <= N; ++i) {
        res = (res + mod * 3 - d[i] * 3) % mod;
    }
    d.assign(2 * N, 0);
    d[N] = 1;
    for (int i = 0; i < n; ++i) {
        dd.assign(2 * N, 0);
        for (int j = 0; j < d.size(); ++j) {
            int k = j + a[i];
            if (k < d.size()) {
                dd[k] = (dd[k] + d[j]) % mod;
            }
            k = j - a[i];
            if (k >= 0) {
                dd[k] = (dd[k] + d[j]) % mod;
            }
        }
        swap(d, dd);
    }
    res = (res + d[N] * 3) % mod;
    cout << res << endl;


}

//#define LOCAL

int main() {
    ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    solve();


#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif	
    return 0;
}

Measured memory_bytes: 3456
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

int main(){
    int a, b;
    cin >> a;
    cin >> b;
    for(int n=0; n<999; n++){
        for(int x=0; x<499500; x++){
            if(n*(n+1)/2 == a + x && (n+1)*(n+2)/2 == b + x){
                cout << x << endl;
                return 0;
            }
        }
    }
}

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

int main() {
  int N;
  cin >> N;
  int k = 1;
  while (N / (int)pow(10,k)) ++k;
	
  int num[4] = {3,5,7,0};
  int ans = 0;
  for (int i = 0; i < (1 << 2*k); ++i) {
    int x = 0;
    bool used[4] = {0,0,0,0};
    for (int j = 0; j < k; ++j) {
      int t = (i >> 2*j) & 0b11;
      x += num[t] * (int)pow(10, j);
      used[t] = true;
    }
    if (used[0] && used[1] && used[2] && !used[3] && x <= N) ++ans;
  }
  for (int i = 3; i < k; ++i) {
    ans += (int)pow(3,i);
	ans -= 3 * (int)pow(2,i);
    ans += 3;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>

using namespace std;

int main(){
	string S;
	cin>>S;
	int price=700;
	if(S[0]=='o')
		price+=100;
	if(S[1]=='o')
		price+=100;
	if(S[2]=='o')
		price+=100;
		
	cout<<price<<endl;
	return 0;
}

Measured memory_bytes: 256
/*
    author:  Maksim1744
    created: 07.06.2020 15:04:47
*/

#include <bits/stdc++.h>

using namespace std;

#define ll   long long
#define ld   long double

#define mp   make_pair
#define pb   push_back
#define eb   emplace_back

#define sum(a)     ( accumulate ((a).begin(), (a).end(), 0ll))
#define mine(a)    (*min_element((a).begin(), (a).end()))
#define maxe(a)    (*max_element((a).begin(), (a).end()))
#define mini(a)    ( min_element((a).begin(), (a).end()) - (a).begin())
#define maxi(a)    ( max_element((a).begin(), (a).end()) - (a).begin())
#define lowb(a, x) ( lower_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define uppb(a, x) ( upper_bound((a).begin(), (a).end(), (x)) - (a).begin())

template<typename T>             vector<T>& operator--            (vector<T>& v){for (auto& i : v) --i;            return  v;}
template<typename T>             vector<T>& operator++            (vector<T>& v){for (auto& i : v) ++i;            return  v;}
template<typename T>             istream& operator>>(istream& is,  vector<T>& v){for (auto& i : v) is >> i;        return is;}
template<typename T>             ostream& operator<<(ostream& os,  vector<T>& v){for (auto& i : v) os << i << ' '; return os;}
template<typename T, typename U> istream& operator>>(istream& is, pair<T, U>& p){is >> p.first >> p.second;        return is;}
template<typename T, typename U> ostream& operator<<(ostream& os, pair<T, U>& p){os << p.first << ' ' << p.second; return os;}
template<typename T, typename U> pair<T,U> operator-(pair<T,U> a, pair<T,U> b){return mp(a.first-b.first, a.second-b.second);}
template<typename T, typename U> pair<T,U> operator+(pair<T,U> a, pair<T,U> b){return mp(a.first+b.first, a.second+b.second);}
template<typename T, typename U> void umin(T& a, U b){if (a > b) a = b;}
template<typename T, typename U> void umax(T& a, U b){if (a < b) a = b;}

#ifdef HOME
#define TAG_LENGTH       25
#define LR_LEFT          left
#define LR_RIGHT         right
#define LR_VALUE         value
#define LR_SECOND_VALUE  mn
#include "C:/C++ libs/print.cpp"
#else
#define showl            42;
#define shows            42;
#define show(...)        42;
#define showm(...)       42;
#define showt(...)       42;
#define printTree(...)   42;
#define printGraph(...)  42;
#define printLRTree(...) 42;
#define printMatrix(...) 42;
#define printWGraph(...) 42;
#define debug     if (false)
#endif

void test_case() {
    int n;
    cin >> n;
    vector<ll> a(n);
    cin >> a;
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    reverse(a.begin(), a.end());
    vector<ll> sub;
    auto reduce = [&](ll k) {
        for (auto x : sub) {
            if ((x ^ k) < k) k ^= x;
        }
        return k;
    };
    for (int i = 0; i < n; ++i) {
        ll k = reduce(a[i]);
        if (s[i] == '1' && k != 0) {
            cout << 1 << '\n';
            return;
        }
        if (s[i] == '0' && k != 0) {
            sub.pb(k);
        }
    }
    cout << 0 << '\n';
}

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

    int T;
    cin >> T;
    while (T--) {
        test_case();
    }

    return 0;
}


Measured memory_bytes: 3652
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

fn main(){
    let line = read_as_vec::<i64>();
    let (a, b) = (line[0], line[1]);

    let k = (a+b)/2;

    if (a-k).abs() == (b-k).abs(){
        println!("{}", k);
    }else{
        println!("IMPOSSIBLE");
    }
}


Measured memory_bytes: 4352
n, m = map(int, input().split())
fct = [1, 1]+[0]*m
mod = 10**9+7
for i in range(2, m+1):
    fct[i] = fct[i-1]*i
    fct[i] %= mod
inv = [1, 1]+[0]*m
invf = [1, 1]+[0]*m

for i in range(2, m+1):
    inv[i] = (-inv[mod % i]*(mod//i)) % mod
    invf[i] = invf[i-1]*inv[i] % mod

ans = 0


def chs(x, y):
    return fct[x]*invf[y]*invf[x-y]
def chs2(x,y):
    return fct[x]*invf[x-y]

m_inv = pow(m, mod-2, mod)
mn = pow(m, n, mod)
for i in range(n+1):
    ans += ((-1)**(i % 2))* chs(n, i)*chs2(m-i,n-i)
    ans %= mod
    mn *= (m_inv)
    mn %= mod
    #print(ans,chs(n, i),chs2(m,n-i))
print(ans*chs2(m,n)%mod)


Measured memory_bytes: 103696