akhauriyash/Code-Regression huggingface dataset:
#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 drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;
#define RET(ans) {cout<<ans<<endl;return 0;} 

    // 二次元ベクターの基本
    /*
    vector<vector<int>> dp; // 宣言
    dp.resize(n); // 1次元めの要素数決定
    dp[i].push_back(int); // プッシュバック
    rep(i,n){
        sort(dp[i].begin(),dp[i].end()); // 二次元めを昇順ソート
    }
    */

    // 整数スキャン（複数）
    /*
    int x,y,z;
    scanf("%d%d%d",&x,&y,&z);

    // n個の整数のスキャン
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // 文字列スキャン
    /*
    string s; cin >> s;
    */

    // n個の文字列スキャン
    /*
    vector<string> slist;
    rep(i,n){
        string s; cin >> s;
        slist.push_back(s);
    }
    */

int main() {
    int n;
    cin >> n;
    ll a[n+1] = {};
    srep(i,1,n+1){
        scanf("%lld",&a[i]);
    }


    ll ans = 0;
    ll amari = 0;
    rep(i,n+1){
        if(amari==1){
            if(a[i]>0){
                ans++;
                a[i]--;
            }
            amari=0;
        }
        ans += a[i]/2;
        a[i] = a[i]%2;
        amari = a[i]%2;
    }
    
    cout << ans << endl;
    return 0;
}
 
 


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main()
{
    int n, a, b;
    int c1 = 0;
    int c2 = 0;
    int c3 = 0;
    cin >> n >> a >> b;
    int p[n];
    for (int i = 0; i < n; i++)
    {
        cin >> p[i];
        if (p[i] <= a)
        {
            c1 += 1;
        }
        else if (a + 1 <= p[i] && p[i] <= b)
        {
            c2 += 1;
        }
        else if (b + 1 <= p[i])
        {
            c3 += 1;
        }
    }
    cout << min(c1, min(c2, c3));
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>

using namespace std;


int main(){
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    string ans = "No";
    if ( x+r <= w && x-r >= 0 && y+r <= h && y-r >= 0 ) ans = "Yes";
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3208
#include <bits/stdc++.h>
typedef long long i64;
using std::cout;
using std::endl;
using std::cin;

int main() {
	i64 ans = 0;
	int n; scanf("%d", &n);
	for(int i = 0; i < n; i++) {
		i64 a; scanf("%lld", &a);
		
		ans += a - 1;
	}
	
	printf("%lld", ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//order_of_key(x) : number of items less than x
//find_by_order(x) : iterator to x

#define mem(dp,a)           memset(dp,a,sizeof dp)
#define rep(i,a,b)          for(ll i=a;i<b;i++)
#define pb(x)               push_back(x)
#define mp(x,y)             make_pair(x,y)
#define fastio              ios_base::sync_with_stdio(false);cin.tie(NULL)
#define F                   first
#define S                   second
#define all(v)              (v).begin(),(v).end()
#define pi                  3.14159265359
ll INF=1e18+10;
ll MOD=998244353;
ll mod=1e9+7;

ll expo(ll a,ll b)
{
    ll res=1;
    while(b>0)
    {
        if(b&1)
            res=(res*a)%mod;
        a=(a*a)%mod;
        b=b/2;
    }
    return res;
}

ll inv(ll a)
{
    return expo(a,mod-2);
}

ll C(ll n,ll r)
{
    if(r>(n-r))
        r=n-r;
    ll res=1;
    rep(i,1,r+1)
    {
        res=(res*(n-i+1))%mod;
        res=(res*inv(i))%mod;
    }
    return res;
}

int main()
{
    ll n,a,b;cin>>n>>a>>b;
    ll ans=expo(2,n);
    ans-=1;
    ans=(ans-C(n,a)+mod)%mod;
    ans=(ans-C(n,b)+mod)%mod;
    cout<<ans;
}


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



typedef struct Node{
int key;
struct Node *r;
struct Node *l;
struct Node *p;
}Node;
#define NIL NULL
Node *root;

void insert(int);
void inorder(Node*);
void preorder(Node*);

int main(){
int n,i,x;
char com[20];

scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%s",com);
if(com[0]=='i'){
scanf("%d",&x);
insert(x);
} else if(com[0]=='p'){
inorder(root);
printf("\n");
preorder(root);
printf("\n");
}
}
return 0;
}


void insert(int k){
Node *y=NIL;
Node *x=root;
Node *z;

z=malloc(sizeof(Node));
z->key=k;
z->l=NIL;
z->r=NIL;

while(x!=NIL){
y=x;
if(z->key < x->key){
x=x->l;
} else{
x=x->r;
}
}

z->p=y;
if(y==NIL){
root=z;
}else{
if(z->key < y->key){
y->l=z;
}else{
y->r=z;
}
}
}


void inorder(Node *u){
if(u==NIL)return;
inorder(u->l);
printf(" %d",u->key);
inorder(u->r);
}

void preorder(Node *u){
if(u==NIL)return;
printf(" %d",u->key);
preorder(u->l);
preorder(u->r);
}

Measured memory_bytes: 24040
#include<stdio.h>
int main(){
    long long int i,j,k,x=0,l,n=5,a[6];
        scanf("%lld%lld%lld%lld%lld",&a[0],&a[1],&a[2],&a[3],&a[4]);
    for(j=0;j<=5;j++){
        for(k=0;k<n-1;k++){
            if(a[k]<a[k+1]){
                x=a[k];
                a[k]=a[k+1];
                a[k+1]=x;
            }
        }
    }
    printf("%lld %lld %lld %lld %lld\n",a[0],a[1],a[2],a[3],a[4]);
    return 0;
}

Measured memory_bytes: 596
N, Y = map(int, input().split())
x, y, z = -1, -1, -1

for i in range(N + 1):
    for j in range(N - i + 1):
        k = N - i - j
        if 10000 * i + 5000 * j + 1000 * k == Y:
            x, y, z = i, j, k
            break

print(x, y, z)


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

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

	int a = s[0] - '0', b = s[1] - '0',
		c = s[2] - '0', d = s[3] - '0';

	if (a + b + c + d == 7) cout << a << '+' << b << '+' << c << '+' << d << "=7" << endl;
	else if (a - b + c + d == 7) cout << a << '-' << b << '+' << c << '+' << d << "=7" << endl;
	else if (a + b - c + d == 7) cout << a << '+' << b << '-' << c << '+' << d << "=7" << endl;
	else if (a + b + c - d == 7) cout << a << '+' << b << '+' << c << '-' << d << "=7" << endl;
	else if (a - b - c + d == 7) cout << a << '-' << b << '-' << c << '+' << d << "=7" << endl;
	else if (a - b + c - d == 7) cout << a << '-' << b << '+' << c << '-' << d << "=7" << endl;
	else if (a + b - c - d == 7) cout << a << '+' << b << '-' << c << '-' << d << "=7" << endl;
	else cout << a << '-' << b << '-' << c << '-' << d << "=7" << endl;

	return 0;
}

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

int main()
{
    int n, a[100010];
    cin >> n;

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

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

    long long ans = 1;
    int cnt = 0;
    for (int i = 0; i < n - 1; i++) {
        if (a[i] == a[i + 1]) {
            ans *= 1LL * a[i];
            i++;
            if (++cnt == 2) break;
        }
    }

    cout << (cnt < 2 ? 0 : ans) << endl;

    return 0;
}


Measured memory_bytes: 640
using System;

class ITP1
{
    static void Main()
    {
        int a;
        while (true)
        {
            var str = Console.ReadLine().ToCharArray();
            if (str[0] == '0')
            {
                break;
            }
            a = 0;
            for (int i = 0; i < str.Length; i++)
            {
                a += int.Parse(str[i].ToString());
            }
            Console.WriteLine(a);
        }
    }
}

Measured memory_bytes: 5664
def solve(orig_arr)
  sorted_arr = orig_arr.sort
  smallest = sorted_arr.first
  cost = 0
  visited = {}
  value_to_sorted_index = {}

  sorted_arr.size.times do |i|
    value_to_sorted_index[sorted_arr[i]] = i
  end

  orig_arr.size.times do |i|
    next if visited[i]

    current = i
    sum = 0
    min = Float::INFINITY
    n = 0

    loop do
      visited[current] = true
      n += 1
      value = orig_arr[current]
      min = [value, min].min
      sum += value
      current = value_to_sorted_index[value]
      break if visited[current]
    end

    cost1 = sum + (n - 2) * min
    cost2 = min + sum + (n + 1) * smallest

    cost += [cost1, cost2].min
  end

  cost
end

if $PROGRAM_NAME == __FILE__
  n = gets.to_i

  arr = gets.chomp.split.map(&:to_i)

  puts solve(arr)
end

Measured memory_bytes: 8824
from heapq import heappush, heappop, heapify

N = int(input())
A = [int(x) for x in input().split()]
#print(sorted(A))
counter = {}
for a in A:
    counter[a] = counter.get(a,0)+1

heap = [(-c, a) for a, c in counter.items()]
heapify(heap)
cnt = 0
#print(sorted(heap))
while -heap[0][0] >= 2:
    cnt+=1
    c, a = heappop(heap)
    c = -c
    #print(repr(str(a)), c)
    if c == 2:
        #cca
        #acc
        c1, a1 = heappop(heap)
        c1 = -c1
        heappush(heap, (-(c-1), a))
        if c1-1:
            heappush(heap, (-(c1-1), a1))
    else:
        heappush(heap, (-(c-2), a))
print(len(heap))



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

using namespace std;
typedef long long ll;

const int N = int(1e8) + 7;

void init(){

}

void solve(){
    int a, b;
    scanf("%d %d", &a, &b);
    if(a >= 13) printf("%d\n", b);
    else if (a >= 6 && a <= 12) printf("%d\n", b/2);
    else printf("0\n");
}

const bool mtc = false;

int main(){
    int t;
    if(mtc){
        scanf("%d", &t);
        while(t--) solve();
    }
    else solve();
}


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

typedef long long ll;
#define READ(a) int a; cin >> a;
#define READARR(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define READMAT(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e15;
const ll mod = 1e9 + 7;
int n;
int adj[201][201] = {}, dp[201][201] = {}, col[201] = {}, visited[201] = {};

void dfs (int cur = 1, int c = 0)
{
    visited[cur] = 1;
    col[cur] = c;
    
    FOR (i, 1, n)
        if (adj[cur][i])
        {
            if (!visited[i]) dfs(i, !c);
            else if (col[i] == c) {cout << -1; exit(0);}
        }
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> n;
	FOR (i, 1, n)
	    FOR (j, 1, n)
	    {
	        char ch;
	        cin >> ch;
	        if (ch == '1') adj[i][j] = dp[i][j] = 1;
	        else dp[i][j] = inf;
	    }
    
    dfs();
    FOR (k, 1, n)
        FOR (i, 1, n)
            FOR (j, 1, n)
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
    
    int ans = 0;
    FOR (i, 1, n)
        FOR (j, 1, n)
           if (i != j) ans = max(ans, dp[i][j]);
    
    cout << ans + 1;
}

Measured memory_bytes: 896
N = int(input())
a = [int(i) for i in input().split()]
Alice = 0
Bob = 0
count = 0
while not all((x == 0 for x in a)):
  if count%2 == 0:
    max_value = max(a)
    Alice += max_value
    max_index = a.index(max_value)
    a[max_index] = 0
    count += 1
  elif count%2 == 1:
    max_value = max(a)
    Bob += max_value
    max_index = a.index(max_value)
    a[max_index] = 0
    count += 1
print(abs(Alice - Bob))

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

int main() {
  int D;
  cin >> D;
  
  if(D==25){
    cout << "Christmas" << endl;
  }
  
  if(D==24){
    cout << "Christmas Eve" << endl;
  }
  
  if(D==23){
    cout << "Christmas Eve Eve" << endl;
  }
  
  if(D==22){
    cout << "Christmas Eve Eve Eve" << endl;
  }
  
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>

#define lli long long int

using namespace std;

int main() {
	lli s, x, diff, mini = 1000, ten = 1000, len = 3;
	scanf("%lld", &s);
	while (s > ten) {
		len++;
		ten *= 10;
	}
	while (ten > 100) {
		x = (s % ten) / (ten / 1000);
		diff = abs(x - 753);
		mini = min(mini, diff);
		ten /= 10;
	}
	printf("%lld\n", mini);
	return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main{
	public static void main(String[]args){
		Scanner sc=new Scanner(System.in);

		int n=sc.nextInt();
		long total=0;
		for(int i=n-1;i>0;i--){
			total+=i;
		}
		System.out.println(total);


	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
 
#define FAST ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
 
#define MAXX 10005
 
#define PI   3.14159265358979323846264338327950
 
#define F first
#define S second
 
#define ll 	 long long int
 
#define mod  1000000007



int main()
{
	FAST;
	ll n;
	cin >> n;
	string s;
	cin >> s;
	ll x = n-1;
	ll h = 0;
	for(ll i = 0; i < n -1 ; i++){
		if(s[i]== 'W'){
			for(ll j = x; j >= 0; j --){
				x = j;
			if(s[j] == 'R' ){
				
				break;
			}
			
		}
		if(s[i] == 'W' && s[x] == 'R' & x > i){
			swap(s[x], s[i]);
			h ++;
			x --;
		}
		}
		
	}
	cout << h;
	return 0;
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){

	int flag = 1, c=0;
	string s, sl;

	cin>> s;
	sl.resize(s.size());

	if (s[0] != 'A') flag = 0;

	for (int i = 2;i < s.size() - 1;i++) {
		if (s[i] == 'C') {
			c++;
			s[i] = 'c';
		}
	}
	if (c != 1) flag = 0;

	transform(s.begin(), s.end(), sl.begin(), ::toupper);

	for (int i = 1;i < s.size();i++) {
		if (s[i] == sl[i]) flag = 0;
	}

	//cout << s << endl;
	//cout << sl << endl;

	if (flag) cout << "AC" << endl;
	else cout << "WA" << endl;


}


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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int getRand(int l, int r)
{
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}
  
#define int long long 
#define pb push_back
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define precise(x) fixed << setprecision(x) 

const int MOD = 1e9+7;

int mod_pow(int a,int b,int M = MOD)
{
    int res = 1;
    
    while(b)
    {
        if(b&1) res=(res*a)%M;
        a=(a*a)%M;
        b>>=1;
    }
    
    return res;
}

const int N = 1e5+10;

int h[N];
vi g[N];

void solve()
{
   int n,m;
    cin >> n >> m;
    
    f(i,n) cin >> h[i+1];
    
    int u,v;
    
    f(i,m)
    {
        cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);
    }
    
    int res = 0;
    
    for(int i=1;i<=n;i++)
    {
        int flag = 1;
        
        for(auto x : g[i]) if(h[i] <= h[x]) flag = 0;
            res+=flag;
    }
    
    cout <<res;
    
    
}

signed main()
{
    fast;
    
    int t = 1;
    
//    cin >> t;
    
    while(t--)
        
    solve();
}

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

int main(){
  int A,B,M;
  vector <int> a(100000),b(100000);
  int min_a{100000};
  int min_b{100000};
  
  cin >> A >> B >> M;
  for(int i=0;i<A;i++){
    cin >> a.at(i);
    if(min_a > a.at(i)) min_a = a.at(i);
  }
  //cout << "min_a=" << min_a << endl;
  for(int i=0;i<B;i++){
    cin >> b.at(i);
    if(min_b >b.at(i)) min_b = b.at(i);
  }
  //cout << "min_b" << min_b << endl;
  int min_ab = min_a+min_b;
    
  for(int i=0;i<M;i++){
    int x,y,c;
    cin >> x >>y >> c;
    int c_p=a.at(x-1)+b.at(y-1) -c;
    //cout << "c_p" << c_p << endl;
    if(min_ab>c_p) min_ab=c_p;
    if(min_ab<0) min_ab=0;
  }
  
  
  cout <<min_ab;

  
  return 0;
  
}

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

int main(){
    int n=0;
    cin >> n;
    if(n/100==7||(n-(n/100)*100)/10==7||((n-(n/100)*100)-((n-(n/100)*100)/10)*10)==7)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3596
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools
# from copy import deepcopy, copy

import queue
from collections import deque




def main():
    s = input()
    k = int(input())

    if len(s) == 1:
        print(k // 2)
        sys.exit()
    if len(s) == 2:
        if s[0] == s[1]:
            print(k)
        else:
            print(0)
        sys.exit()


    s = list(s)
    s2 = []
    for i in range(2):
        for ele in s:
            s2.append(ele)
    s3 = []
    for i in range(3):
        for ele in s:
            s3.append(ele)

    s4 = []
    for i in range(4):
        for ele in s:
            s4.append(ele)

    count = 0
    for i in range(len(s) - 1):
        if s[i + 1] == s[i]:
            s[i + 1] = -1
            count += 1

    count2 = 0
    for i in range(len(s2) - 1):
        if s2[i + 1] == s2[i]:
            s2[i + 1] = -1
            count2 += 1

    count3 = 0
    for i in range(len(s3) - 1):
        if s3[i + 1] == s3[i]:
            s3[i + 1] = -1
            count3 += 1

    count4 = 0
    for i in range(len(s4) - 1):
        if s4[i + 1] == s4[i]:
            s4[i + 1] = -1
            count4 += 1


    if k == 1:
        print(count)
    elif k == 2:
        print(count2)
    elif k == 3:
        print(count3)
    elif k == 4:
        print(count4)
    else:
        if k % 2:
            ans = count2 + ((k - 2) // 2) * (count4 - count2) + (count3 - count2)
        else:
            ans = count2 + ((k - 2) // 2) * (count4 - count2)

        print(ans)








if __name__ == '__main__':
    main()


Measured memory_bytes: 38636
n = int(input())
name = []
for _ in range(n):
  s,t = input().split()
  t = int(t)
  name.append((s,t))
  
x = input()
flg = False
ans = 0
for i in range(n):
  if flg:
    ans += name[i][1]
    
  if name[i][0] == x:
    flg = True
    
print(ans)
    

Measured memory_bytes: 38256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const long long MAXN=100005;
long long n;
long long a[MAXN];
long long gcd(long long a,long long b)
{
	return b==0?a:gcd(b,a%b);
}
void pr(long long x)
{
	if(x==1)
		printf("First\n");
	else
		printf("Second\n");
	exit(0);
}
void dfs(long long x)
{
	long long s=0;
	for(long long i=1;i<=n;i++)
		s+=a[i]-1;
	if(s&1)
		pr(x^1);
	long long cnt=0;
	for(long long i=1;i<=n;i++)
		if(a[i]&1)
			cnt++;
	for(long long i=1;i<=n;i++)
		if(a[i]==1)
			cnt=903;
	if(cnt!=1)
		pr(x);
	for(long long i=1;i<=n;i++)
		if(a[i]&1)
		{
			a[i]--;
			break;
		}
	long long G=0;
	for(long long i=1;i<=n;i++)
		G=gcd(G,a[i]);
	for(long long i=1;i<=n;i++)
		a[i]/=G;
	dfs(x^1);
}
int main()
{
	scanf("%lld",&n);
	for(long long i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
	}
	dfs(0);
}

Measured memory_bytes: 896
N, K = map(int, input().split())
Max = [0]
Min = [0]
for i in range(1, N+2):
  Max.append(N-i+1+Max[i-1])
  Min.append(i-1+Min[i-1])
A = [mx-mn+1 for mx,mn in zip(Max,Min)]
B =[0]
for i in range(N+1):
  B.append(B[i]+A[i+1])
print((B[N+1]-B[K-1])%(10**9+7))

Measured memory_bytes: 52296
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>
#include <set>
#include <map>
#include <type_traits>
#include <cstdint>

typedef long long ll;

using namespace std;

//素因数分解
void factoring(ll n, map<ll, ll>& mp) {
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			mp[i]++;
			n /= i;
		}
	}
	if (n != 1) mp[n]++;
}

//絶対値
template<class T, class U = std::make_unsigned_t<T>>
U SafeAbs( T x ) {
    return x < 0 ? -static_cast<uintmax_t>(x) : x;
}

//最大・最小
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//xのn乗
ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
//xの逆元
ll mod_inv(ll x, ll mod) {//O(log(mod))
    return mod_pow(x, mod - 2, mod);
}

//nCr
ll ncr(ll n, ll r, ll mod){
	ll res=1;
	ll num=1,den=1;
	for(ll i=n;i>=n-r+1;i--){
		(den*=i)%=mod;
	}
	for(ll i=1;i<=r;i++){
		(num*=i)%=mod;
	}
	
	res=den*mod_inv(num,mod);

	return res%mod;
}


//二分探索
bool isOk(ll index, ll key,vector<ll> &a, bool g){
	if(g){
		if(a[index]<key){
			return true;
		}
	}
	else{
		if(a[index]>key){
			return true;
		}
	}
	return false;
}

ll bin_search(ll key, vector<ll> &a, bool g){
	
	ll l=-1;
	ll r=a.size();

	if(g){
		l=a.size();
		r=-1;
	}

	while(abs(r-l)>1){
		ll mid = (l+r)/2;
		if(isOk(mid, key, a, g)){
			r=mid;
		}
		else{
			l=mid;
		}
	}
	return r;
}

int main(){

	ll n;
	cin>>n;

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

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

	ll ans=0;

	for(ll i=0;i<n;i++){
		ans+=(bin_search(b[i],a,true)+1)*(n-bin_search(b[i],c,false));
	}


	cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 2560
import java.util.*;
public class Main {
  	static int mod = 1000000007;
public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	// 整数の入力
	long S = sc.nextLong();
    long tani = 1000000000L;
  	long i =1;

	if(S<=tani){
      System.out.println("0 0 0 1 "+S+" 0");
    }else if(S%tani==0){
      System.out.println("0 0 0 "+(S/tani)+" "+tani+" 0");
    }else{
      i=S/tani;
      System.out.println("0 0 "+((i+1)*tani-S)+" "+ (i+1)+" "+tani+ " 1");
    }
  }
} 

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

#define mp make_pair
#define sz(x) (int)((x).size())
#define all(x) (x).begin(),(x).end()
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define eb emplace_back

typedef pair< int, int > pii;
typedef pair< long long, long long > pll;
typedef long long ll;
typedef unsigned long long ull;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef vector< ll > vll;
typedef vector< vll > vvll;
typedef vector< pii > vpii;
typedef vector< vpii > vvpii;
typedef vector< pll > vpll;
typedef long double ld;
typedef vector< ld > vld;
typedef unsigned int uint;
 
template <uint MD> struct ModInt {
    using M = ModInt;
    const static M G;
    uint v;
    ModInt(ll _v = 0) { set_v(uint(_v % MD + MD)); }
    M& set_v(uint _v) {
        v = (_v < MD) ? _v : _v - MD;
        return *this;
    }
    explicit operator bool() const { return v != 0; }
    M operator-() const { return M() - *this; }
    M operator+(const M& r) const { return M().set_v(v + r.v); }
    M operator-(const M& r) const { return M().set_v(v + MD - r.v); }
    M operator*(const M& r) const { return M().set_v(uint(ull(v) * r.v % MD)); }
    M operator/(const M& r) const { return *this * r.inv(); }
    M& operator+=(const M& r) { return *this = *this + r; }
    M& operator-=(const M& r) { return *this = *this - r; }
    M& operator*=(const M& r) { return *this = *this * r; }
    M& operator/=(const M& r) { return *this = *this / r; }
    bool operator==(const M& r) const { return v == r.v; }
    const bool operator<(const M& o) const {return v < o.v; }
    M pow(ll n) const {
        M x = *this, r = 1;
        while (n) {
            if (n & 1) r *= x;
            x *= x;
            n >>= 1;
        }
        return r;
    }
    M inv() const { return pow(MD - 2); }
    friend ostream& operator<<(ostream& os, const M& r) { return os << r.v; }
};
 
using Mint = ModInt<(int)1e9 + 7>;
 
int main() { 
    #ifdef BLAT
        freopen("stdin", "r", stdin);
        freopen("stderr", "w", stderr);
    #endif
 
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(12);
    srand(time(NULL));
    
    int a, b;
    cin >> a >> b;

    cout << 1ll*a*b;
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
  if ((x += a.x) >= mod) x -= mod;
  return *this;
  }
  mint& operator-=(const mint a) {
  if ((x += mod-a.x) >= mod) x -= mod;
  return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
  if (!t) return 1;
  mint a = pow(t>>1);
  a *= a;
  if (t&1) a *= *this;
  return a;
  }
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

vector<mint> dp(200009, 0);
//dp.at(i)でiだけ進む方法の数
vector<mint> S(200009, 0);
//S.at(i)で0~i-1だけ進む方法の数の和

int main()
{
    ll N, K;
    cin >> N >> K;
    vector<ll> L(K), R(K);
    rep(i, K){
        cin >> L.at(i) >> R.at(i);
    }
    sort(all(L));
    sort(all(R));
    dp.at(0) = 1;
    S.at(1) = 1;
    rep2(i, 1, N+1){
        ll pos = -1;
        // L.at(pos) <= i < L.at(pos+1)
        if(K == 1){
            if(L.at(0) <= i){
                pos = 0;
            }
        }
        rep(j, K-1){
            if(L.at(j) <= i && i < L.at(j+1)){
                pos = j;
                break;
            }
            if(j == K-2){
                if(L.at(K-1) <= i){
                    pos = K-1;
                    break;
                }
                else{
                    pos = -1;
                    break;
                }
            }
        }
        rep(j, pos+1){
            if(R.at(j) <= i){
                dp.at(i) += S.at(i-L.at(j)+1) - S.at(i-R.at(j));
            }
            else{
                dp.at(i) += S.at(i-L.at(j)+1);
            }
        }
        S.at(i+1) = S.at(i) + dp.at(i);
    }
//    rep(i, N+1){
//        cout << dp.at(i) << endl;
//    }
    cout << dp.at(N-1) << endl;
}

Measured memory_bytes: 6232
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;

struct Node {
  int key;
  Node *prev, *next;
};

Node *nil;

void init() {
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

void insert(int key) {
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;

  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

Node* listSearch(int key) {
  Node *cur = nil->next;
  while (cur != nil && cur->key != key) {
    cur = cur->next;
  }
  return cur;
}

void printList() {
  Node *cur = nil->next;
  int i = 0;
  while ( 1 ) {
    if ( cur == nil ) break;
    if ( i++ > 0 ) printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
  }
  printf("\n");
}

void deleteNode(Node *t) {
  if ( t == nil ) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst() {
  deleteNode(nil->next);
}

void deleteLast() {
  deleteNode(nil->prev);
}

void deleteKey(int key) {
  deleteNode(listSearch(key));
}

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

  int i, n, key;
  char command[20];

  scanf("%d", &n);
  init();
  
  for ( i = 0 ; i < n ; i++ ) {
    scanf("%s%d", command, &key);

    if ( command[0] == 'i' ) {
      insert(key);
    }
    else if ( command[6] == 'F' ) {
      deleteFirst();
    }
    else if ( command[6] == 'L' ) {
      deleteLast();
    }
    else {
      deleteKey(key);
    }
  }

  printList();
}



Measured memory_bytes: 33868
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    string s,t;
    cin>>s>>t;
    ll c=0,M=0;
    rep(0,i,(ll)s.length()){
        if((ll)t.length()+i<=(ll)s.length()){
            rep(i,j,t.length()+i){
                if(s[j]==t[j-i])++c;
                M=max(M,c);
            }
            c=0;
        }
    }
    cout<<t.length()-M;
}

Measured memory_bytes: 3592
"""
https://atcoder.jp/contests/abc087/tasks/arc090_b

xR-xL = D
Mこの情報が正しいかどうかの判定
グループを作って、グループ内の拘束条件があっているか確認
重み付きunionfindを使う
https://qiita.com/drken/items/cce6fc5c579051e64fab
http://at274.hatenablog.com/entry/2018/02/03/140504


5 5
1 2 2
2 3 3
4 5 4
2 5 10
3 4 3
"""

from collections import defaultdict
class UnionFind:
    def __init__(self, n):
        class KeyDict(dict):
            # 辞書にないときの対応
            def __missing__(self,key):
                self[key] = key
                return key
        self.parent = KeyDict()
        self.rank = defaultdict(int)
        self.weight = defaultdict(int)

    # 根を探す
    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            # 経路圧縮
            # 自分自身じゃない場合は、上にさかのぼって検索(再帰的に)
            y = self.find(self.parent[x])           
            self.weight[x] += self.weight[self.parent[x]]   #圧縮時にweightを更新(和)
            self.parent[x] = y      #親の置き換え(圧縮)
            return self.parent[x]

    # 結合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        # 低い方を高い方につなげる(親のランクによる)
        if self.rank[x] < self.rank[y]:
            self.parent[x] = y
        else:
            self.parent[y] = x
        
        if self.rank[x] == self.rank[y]:
            self.rank[x] += 1

    ### 重みが正負逆になる。なんでだ
    def weighted_union(self, x, y, w):
        # print("unite",x,y,w,self.weight)
        px = self.find(x)
        py = self.find(y)
        # 低い方を高い方につなげる(親のランクによる)
        # if px == py: return 0
        if self.rank[px] < self.rank[py]:
            self.parent[px] = py
            self.weight[px] = - w - self.weight[x] + self.weight[y]
        else:
            self.parent[py] = px
            self.weight[py] =  w + self.weight[x] - self.weight[y]
        if self.rank[px] == self.rank[py]:
            self.rank[px] += 1
        return 0


    # 判定
    def judge(self, x, y):
        return self.find(x) == self.find(y)


N,M = map(int, input().split())
uf = UnionFind(N)
for i in range(N):
    uf.find(i)

for i in range(M):
    l,r,d = map(int, input().split())
    # 初めて出てくる奴らは数直線形成に使う
    if not uf.judge(l, r):
        uf.weighted_union(l, r, d)
    # 二回目のやつらは後で拘束条件に使う
    else:
        if d == uf.weight[r] - uf.weight[l]:
            continue
        else:
            print("No")
            exit()
print("Yes")
# for i in uf.parent.keys():
#     uf.find(i)
#     print("index:{} rank:{}, parent:{}, weight:{}".format(i,uf.rank[i],uf.parent[i],uf.weight[i]))


Measured memory_bytes: 38756
#include <iostream>
#include <vector>

int main() {
    size_t n;
    std::cin >> n;

    std::vector<size_t> h(n);
    for (auto&& hi : h) std::cin >> hi;

    size_t max = 0;
    size_t count = 0;
    for (size_t i = 0; i < n - 1; ++i) {
        if (h[i] >= h[i + 1]) {
            ++count;
        } else {
            if (max < count) max = count;
            count = 0;
        }
    }
    if (max < count) max = count;

    std::cout << max << std::endl;
}

Measured memory_bytes: 1024
fn input_trio<T: std::str::FromStr + Copy> () -> (T, T, T) {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let arr: Vec<_> = s.trim().split_whitespace().flat_map(str::parse).collect();
    (arr[0], arr[1], arr[2])
}

fn main() {
    let (a, b, c) = input_trio::<usize>();
    println!("{}", if a + b + c >= 22 {
        "bust"
    } else {
        "win"
    });
}


Measured memory_bytes: 2092
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)


int main(){
   int n;
   cin >> n;
   int a[n],b[n],c[n-1];
   REP(i,n) cin >> a[i];
   REP(i,n) cin >> b[i];
   REP(i,n-1) cin >> c[i];
   
   int manzoku=0;
   int mae=-10;
   REP(i,n){
      manzoku += b[a[i]-1];
      if(a[i] == mae + 1) manzoku += c[mae-1];
      mae = a[i];
   }
   
   cout << manzoku << endl;
   
   
   
   
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rrep(i, n, g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(x) (int)(x).size()
#define dup(x, y) (((x) + (y)-1) / (y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int h, a;
  cin >> h >> a;
  if (h % a == 0)
    cout << h / a << endl;

  else
    cout << h / a + 1 << endl;
}

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

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v) {
    if (v.size()) {
        os << v.front();
        for (auto vi = v.begin() + 1; vi != v.end(); vi++)
            os << " " << *vi;
    }
    return os;
}

int selection_sort_counter(vector<int> &a)
{
    int count = 0;

    for (int i = 0; i < a.size(); i++) {
        int mini = i;
        for (int j = i; j < a.size(); j++)
            if (a[j] < a[mini])
                mini = j;
        if (i != mini) {
            swap(a[i], a[mini]);
            count++;
        }
    }

    return count;
}

int main()
{
    int n, count;
    cin >> n;
    vector<int> array(n);


    for (int x, i = 0; i < n && cin >> x; i++)
        array[i] = x;

    count = selection_sort_counter(array);

    cout << array << endl;
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 1196
#include<iostream>
#include<stdio.h>
using namespace std;
 
int main(){
int debt = 100000, n;
cin >> n;
for(;n>0;n--){
        debt = debt * 1.05;
        if((debt % 1000)>0)
{        debt = debt - (debt % 1000);        debt += 1000;        }
        }

cout << debt << endl;
 
return 0;
}

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

const int MAXN = 1e5;
const ll MOD = 1e9 + 7;
int N, K, A[MAXN];
ll cache[MAXN];

ll modpow(int a, int n) {
    ll ret = 1;
    while(n > 0) {
        if(n % 2 == 1) ret = ret * a % MOD;
        a = (ll)a * a % MOD;
        n /= 2;
    }
    return ret;
}

ll inv(int x) {
    return modpow(x, MOD - 2);
}

ll combination(int n) {
    ll &ret = cache[n];
    if(ret != -1) return ret;
    if(n == K - 1) return ret = 1;
    return ret = combination(n - 1) * n % MOD * inv(n - K + 1) % MOD;
}

int main() {
    cin >> N >> K;
    for(int i = 0; i < N; ++i) cin >> A[i];
    sort(A, A + N);
    ll ans = 0;
    memset(cache, -1, sizeof(cache));
    for(int i = 0; i < N; ++i) {
        ll minCnt = 0, maxCnt = 0;
        // if A[i] is minValue of S, minCnt = choose K - 1 in {i + 1, ... N - 1}
        // if A[i] is maxValue of S, maxCnt = choose K - 1 in {0, ... i - 1}
        if(i <= N - K) maxCnt = combination(N - i - 1); 
        if(i >= K - 1) minCnt = combination(i);
        ans = (ans + (minCnt - maxCnt) * A[i] % MOD) % MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2944
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15


N,K = map(int,input().split())
W = [int(input()) for _ in range(N)]

r = 10 ** 10
l = 0
def ok(x):
    cnt = 1
    tot = 0
    for i in range(N):
        if tot + W[i] <= x:
            tot += W[i]
        else:
            cnt += 1
            if W[i] > x:
                return False
            tot = W[i]
    return cnt <= K      

while r - l > 1:
    mid = (r + l)//2
    if ok(mid):
        r = mid
    else:
        l = mid
print(r)



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

int cupA,cupB,cupC;

bool check(int cup){
	if(cup==1)return true;
	else return false;
}

int WtoB(int cup){
	if(cup==1)return 0;
	else return 1;
}

void func(char c1,char c2){
	if(c1=='A'){
		if(c2=='B'){
			if(check(cupA) || check(cupB)){
				cupA=WtoB(cupA);
				cupB=WtoB(cupB);
			}
		}else{
			if(check(cupA) || check(cupC)){
				cupA=WtoB(cupA);
				cupC=WtoB(cupC);
			}
		}
	}else if(c1=='B'){
		if(c2=='A'){
			if(check(cupB) || check(cupA)){
				cupB=WtoB(cupB);
				cupA=WtoB(cupA);
			}
		}else{
			if(check(cupB) || check(cupC)){
				cupB=WtoB(cupB);
				cupC=WtoB(cupC);
			}
		}
	}else if(c1=='C'){
		if(c2=='A'){
			if(check(cupC) || check(cupA)){
				cupC=WtoB(cupC);
				cupA=WtoB(cupA);
			}
		}else{
			if(check(cupC) || check(cupB)){
				cupC=WtoB(cupC);
				cupB=WtoB(cupB);
			}
		}
	}
}
		

int main(){
	char cup1,cup2;
	string ss;
	cupA=1;
	cupB=0;
	cupC=0;
	while(cin>>ss){
		cup1=ss[0];
		cup2=ss[2];
		func(cup1,cup2);
	}
	if(cupA==1)cout<<'A'<<endl;
	else if(cupB==1)cout<<'B'<<endl;
	else cout<<'C'<<endl;
	return 0;
}

Measured memory_bytes: 1172
import java.util.*;
import java.math.*;
class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for(int i = 0; i < n; i++) {
			BigInteger x = sc.nextBigInteger().add(sc.nextBigInteger());
			System.out.println(x.toString().length() > 80 ? "overflow" : x);
		}
	}
}

Measured memory_bytes: 26356
#include <cstdio>
#include <cmath>
#include <climits>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <cassert>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <fstream>
#include <functional>
#include <utility>
#include <map>
#include <set>
#include <vector>
#include <list>
#include <iomanip>
#define memtst(x) (sizeof(x) / 1024. / 1024.)
#define mem0(x) memset((x), 0, (sizeof x))
#define meminf(x) memset((x), INF, (sizeof x))
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define pq std::priority_queue
#define iter iterator
#define mp(x, y) std::make_pair((x), (y))
#define fst first
#define sec second
#define lc(x) ((x) * 2)
#define rc(x) ((x) * 2 + 1) 
#define md(x, y) (((x) + (y)) / 2)
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef std::pair <ll, ll> pii;
const double PI = acos(-1);
const double EPS = 1e-6;
const ll MOD = 1000000007;
const ll INF = 0x3F3F3F3F;
template <typename T>
inline T Abs(T x)
{
    return x < 0 ? x * -1 : x;
}
template <typename T>
inline T Max(T x, T y, T z)
{
    return std::max(std::max(x, y), z);
}
template <typename T>
inline T Min(T x, T y, T z)
{
    return std::min(std::min(x, y), z);
}
template <typename T>
inline T Ckmax(T &x, T y)
{
    return x = std::max(x, y);
}
template <typename T>
inline T Ckmin(T &x, T y)
{
    return x = std::min(x, y);
}
template <typename T>
inline T Sqr(T x)
{
    return x * x;
}
template <typename T>
inline T Pow(T x, T y)
{
    T r = 1;
    while (y > 0)
    {
        if (y % 2 > 0)
            (r *= x) %= MOD;
        (x *= x) %= MOD;
        y /= 2;
    }
    return r % MOD;
}
template <typename T>
T Pow(T x, T y, T z)
{
    T r = 1;
    while (y > 0)
    {
        if (y % 2 > 0)
            (r *= x) %= z;
        (x *= x) %= z;
        y /= 2;
    }
    return r % z;
}
template <typename T>
inline T gcd(T x, T y)
{
    return y > 0 ? gcd(y, x % y) : x;
}
template <typename T>
inline T lcm(T x, T y)
{
    return x / gcd(x, y) * y;
}
inline void cinspu(void)
{
    std::ios::sync_with_stdio(0);
    std::cin.tie(0);
    std::cout.tie(0);
}
inline ll read(void)
{
    char x;
    while (x = getchar(), x != '-' && !isdigit(x))
        ;
    char flg = x == '-';
    ll num = (flg ? getchar() : x) - '0';
    while (isdigit(x = getchar()))
        (num *= 10) += x - '0';
    return flg ? -num : num;
}
const int N = 2e5 + 10;
char s[N];
int main()
{
	cinspu();
	std::cin >> (s + 1);
	int n = strlen(s + 1);
	ll ans = 0;
	for (int i = 1, j = 0; i <= n; ++i)
		if (s[i] == 'W')
			ans += i - (++j);
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 512
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    void solve(Scanner sc, PrintWriter pw) {
        long N = sc.nextLong();
        pw.println(func(N - 1));
    }

    private String func(long n) {
        if (n < 26) {
            return String.valueOf((char)('a' + n));
        }
        return func(n / 26 - 1) + String.valueOf((char)('a' + (n % 26)));
    }

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        new Main().solve(sc, pw);
        pw.flush();
        pw.close();
        sc.close();
    }
}


Measured memory_bytes: 39604
from collections import deque

N, M = map(int, input().split())
A, B = [], []
graph = [[] for i in range(N+1)]
for i in range(M):
    a, b = map(int, input().split())
    graph[a].append(b)
    graph[b].append(a)

visited = [False for i in range(N+1)]
signs   = [-1 for i in range(N+1)]

D = deque([1])
while D:
    n = D.popleft()
    for node in graph[n]:
        if visited[node] is True:
            continue
        else:
            visited[node] = True
            signs[node] = n
            D.append(node)
print("Yes")
for sign in signs[2:]:
    print(sign)


Measured memory_bytes: 35668
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	n, err := strconv.Atoi(nextString())
	if err != nil {
		fmt.Printf("strconv.Atoi failed: %v\n", err)
	}
	return n
}

func nextFloat64() (float64, error) {
	return strconv.ParseFloat(nextString(), 64)
}

func main() {
	scanner.Split(bufio.ScanWords)

	for {
		var s int
		var w, h float64
		_, err := fmt.Scanf("%d,%f,%f", &s, &w, &h)

		if err != nil {
			break
		}

		if w/(h*h) >= 25 {
			fmt.Println(s)
		}
	}
}



Measured memory_bytes: 1164
// https://qiita.com/drken/items/a207e5ae3ea2cf17f4bd を参考に
// 難しい、まだ100%は理解できていない

#include<iostream>
#include<vector>
using namespace std;

int main(){
    string s;
    cin >> s;
    int n = s.length();
    vector<vector<int>> v(n+1, vector<int>(26, n));
    for(int i = n-1; i >= 0; i--){
        for(int j = 0; j < 26; j++){
            v[i][j] = v[i+1][j];
        }
        v[i][s[i]-'a'] = i;
    }
    vector<int> dp(n+1, 1<<30);
    vector<char> mem(n);
    dp[n] = 1;
    for(int i = n-1; i >= 0; i--){
        for(int j = 0; j < 26; j++){
            if(v[i][j] == n){
                if(dp[i] == 1)  continue;
                dp[i] = 1;
                mem[i] = (char)('a'+j);
            }else{
                if(dp[i] > dp[v[i][j]+1]+1){
                    dp[i] = dp[v[i][j]+1]+1;
                    mem[i] = (char)('a'+j);
                }
            }
        }
    }
    int pos = 0;
    while(pos < n){
        cout << mem[pos];
        pos = v[pos][mem[pos]-'a']+1;
    }
    cout << endl;
    return 0;
}


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

#define for_(i,a,b) for(int i=(a);i<(b);++i)

int H, W;
string grid[8];

bool check() {
	for_(y,0,H) for_(x,0,W) if (grid[y][x] == '#') return false;
	return true;
}

bool rec(int x, int y) {
	if ((x == W-1 || grid[y][x+1] == '.') &&
		(y == H-1 || grid[y+1][x] == '.')) {
		return check();
	}
	
	bool res = false;
	if (x < W-1 && grid[y][x+1] == '#') {
		grid[y][x+1] = '.';
		res |= rec(x+1, y);
		grid[y][x+1] = '#';
	}
	
	if (y < H-1 && grid[y+1][x] == '#') {
		grid[y+1][x] = '.';
		res |= rec(x, y+1);
		grid[y+1][x] = '#';
	}
	
	return res;
}

int main() {
	cin >> H >> W;
	for_(i,0,H) cin >> grid[i];
	grid[0][0] = '.';
	puts(rec(0,0) ? "Possible" : "Impossible");
}

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

typedef long long ll;
const ll INF = 1LL<<60, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define all(v) (v).begin(), (v).end()
#define first fi
#define second se

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n,x,ans=0;
  cin >> n >> x;
  vector<ll> l(n);
  rep(i,n) cin >> l[i];
  ll d[150];
  d[0] = 0;
  rep(i,n){
    ans++;
    d[i+1] = d[i] + l[i];
    if(d[i+1]<=x && i==n-1){
      ans++;
      break;
    }
    else if(d[i+1] > x) break; 
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define FIFO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define MOD 1000000007
#define mods 1000000009
#define modhash1 1000000009
#define modhash2 1000000007
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;
int TestMillerRabin[12] = {2,3,5,7,11,13,17,19,23,29,31,37};
ll mulmod(ll a, ll b, ll p){
	ll x = 0, y = a%p;
	while(b>0){
		if(b%2==1) x = (x+y)%p;
		y = (1LL*y*2)%p;
		b = b/2;
	}
	return x%p;
}
ll fastexp(ll x, ll y, ll p){
	ll ans = 1;
	while(y > 0){
		if(y&1) ans = (1LL*ans*x)%p;
		y = y>>1;
		x = (1LL*x*x)%p;
	}
	return ans%p;
}
ll fastexpp(ll x, ll y, ll p){
	ll ans = 1;
	while(y > 0){
		if(y&1) ans = mulmod(ans,x,p);
		y = y>>1;
		x = mulmod(x,x,p);
	}
	return ans%p;
}
ll invmod(ll x, ll p){
	return fastexp(x,p-2,p)%p;
}
bool check_composite(ll n, ll a, ll d, int s){
	ll x = fastexp(a,d,n);
	if(x == 1 || x == n-1) return false;
	for(int r=1; r<s; r++){
		x = (1LL*x*x)%n;
		if(x == n-1) return false;
	}
	return true;
}
bool isPrime(ll p){
	if(p<=1) return false;
	int r = 0;
	ll d = p-1;
	while(!(d&1)){
		d >>= 1;
		r++;
	}
	for(int i=0; i<12; i++){
		int value = TestMillerRabin[i];
		if(p == value) return true;
		if(check_composite(p,value,d,r)) return false;
	}
	return true;
}

int main(){
	int h1, h2, m1, m2, k;
	cin >> h1 >> m1 >> h2 >> m2 >> k;
	int n1 = h1*60+m1;
	int n2 = h2*60+m2;
	int end = max(n1,n2-k);
	cout << end-n1 << '\n';
	return 0;
}


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

int main(){
    ll N, K; cin >> N >> K;

    if(K==0){
        cout << N * N << endl;
        return 0;
    }

    ll cnt = 0;
    for (int i = 1; i <= N; i++)
    {
        int p = N/i;
        int q = N%i;
        cnt += max(0LL, i-K) * p + max(0LL, q-K+1);
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256