akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

#define ll          long long
#define pb          push_back
#define pii         pair<ll,ll>
#define vpii        vector< pii >
#define vi          vector<ll>
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			1'010'000'000'000'000'017LL
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define sz(x)       (ll)x.size()
#define rep(i,a,b)	for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )

using namespace std;

template<class T>
bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>
bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
ll DivisorCount(ll x) {
	ll ans = 1;
	for (int i = 2; i <= sqrt(x); i++) {
		int cnt = 0;
		while (x % i == 0) {
			cnt++;
			x /= i;
		}
		ans *= (cnt + 1);
		if (x == 1) break;
	}
	if (x != 1) ans *= 2;
	return ans;
}
ll Digit(ll x) {
	return log10(x) + 1;
}


void Main() {
	ll N;
	cin >> N;
	vi A(N, 1);
	rep(i, 0, N) {
		cin >> A[i];
		if (A[i] == 0) {
			cout << 0 << endl;
			return;
		}
	}
	ll ans = 1;
	ll max = pow(10, 18);
	rep(i, 0, N) {
		if (A[i] > max / ans) {
			cout << -1 << endl;
			return;
		}
		ans *= A[i];
	}
	cout << ans << endl;
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);

	Main();
	return 0;
}


Measured memory_bytes: 3996
using System.Text;

namespace aoj
{
    using System;

    class Node
    {
        public int key;
        public Node parent, left, right;

        public Node(int x)
        {
            key = x;
        }
    }

    class Tree
    {
        private Node root;

        public void Insert(Node z)
        {
            Node y = null;
            Node x = root;
            while (x != null)
            {
                y = x;
                x = z.key < y.key ? x.left : x.right;
            }

            z.parent = y;
            if (y == null)
            {
                root = z;
            }
            else if (z.key < y.key)
            {
                y.left = z;
            }
            else
            {
                y.right = z;
            }
        }

        public bool Find(int x)
        {
            Func<int, Node, bool> f = null;
            f = (xx, n) =>
            {
                if (n == null) return false;
                if (xx == n.key) return true;
                if (xx < n.key) return f(xx, n.left);
                else return f(xx, n.right);
            };
            return f(x, root);
        }

        public void Preorder()
        {
            Func<StringBuilder, Node, StringBuilder> f = null;
            f = (sb, n) =>
            {
                if (n == null) return sb;
                sb.Append(String.Format(" {0}", n.key));
                f(sb, n.left);
                f(sb, n.right);
                return sb;
            };
            var sb1 = new StringBuilder();
            f(sb1, root);
            Console.WriteLine(sb1.ToString().TrimEnd());
        }

        public void Inorder()
        {
            Func<StringBuilder, Node, StringBuilder> f = null;
            f = (sb, n) =>
            {
                if (n == null) return sb;
                f(sb, n.left);
                sb.Append(String.Format(" {0}", n.key));
                f(sb, n.right);
                return sb;
            };
            var sb1 = new StringBuilder();
            f(sb1, root);
            Console.WriteLine(sb1.ToString().TrimEnd());
        }
    }


    class Program
    {
        void Solve()
        {
            var n = int.Parse(Console.ReadLine());
            var tree = new Tree();
            for (var i = 0; i < n; i++)
            {
                var lines = Console.ReadLine().Split();
                switch (lines[0])
                {
                    case "insert":
                        var nn = int.Parse(lines[1]);
                        tree.Insert(new Node(nn));
                        break;
                    case "find":
                        var nnn = int.Parse(lines[1]);
                        var f = tree.Find(nnn);
                        Console.WriteLine(f ? "yes" : "no");
                        break;
                    default:
                        tree.Inorder();
                        tree.Preorder();
                        break;
                }
            }
        }

        static void Main(string[] args)
        {
            new Program().Solve();
        }
    }
}


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

using namespace std;

const int maxn = 3e5+10;

int a[maxn],n,k;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>k>>n;
    if (k%2==0) {
        cout<<k/2<<" ";
        for (int i=1;i<n;i++) cout<<k<<" ";
    } else {
        int num = n/2;
        int id = n-1;
        for (int i=0;i<n;i++) a[i] = (k+1)/2;
        while (num--) {
            if (a[id]==1) {
                id--;
                continue;
            }
            a[id]--;
            while (id+1 < n) a[++id]=k;
        }
        for (int i=0;i<=id;i++) cout<<a[i]<< " ";
    }
}


Measured memory_bytes: 3456
import sys
from collections import Counter
from string import ascii_lowercase

n, *s = sys.stdin.read().split()
n = int(n)

def main():
    cnt = [Counter(s[i]) for i in range(n)]
    
    for i in range(n - 1):
        for c in ascii_lowercase:
            cnt[i+1][c] = min(cnt[i+1][c], cnt[i][c])
    res = ''
    for v, c in sorted(cnt[-1].items()):
        res += v * c
    print(res)

if __name__ ==  '__main__':
    main()

Measured memory_bytes: 3768
#https://atcoder.jp/contests/abc126/tasks/abc126_c
N, K = map(int, input().split())
ans = 0
for i in range(1, N+1):
    now = i
    p = 1
    while now < K:
        now *= 2
        p *= 1/2
    ans += p * 1/N  
print(ans)




Measured memory_bytes: 2940
s = gets.chomp.chars

if s[0] != 'A'
  puts 'WA'
  exit
end

if s[2..-2].count('C') != 1
  puts 'WA'
  exit
end

s.shift

if s.count('C') != 1
  puts 'WA'
  exit
end


s.each do |i|
  if !i.match(/[a-zC]/)
    puts 'WA'
    exit
  end
end

puts 'AC'

Measured memory_bytes: 1788
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#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;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long 
#define mod 1000000007
#define inf 100000000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define f first
#define s second
#define pb push_back
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
int main(){
	//mahakal(),fast;
	
	ll n ;
	cin>> n ;
	string str;
	cin>> str ;
	auto it=unique(str.begin(),str.end());

	ll ans = it-str.begin();
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace COJ1_7
{
    struct Node
    {
        public int value;
        public int left;
        public int right;
    }
    class Program
    {

        static void Main(string[] args)
        {
            int cnt = int.Parse(Console.ReadLine());
            Node[] nodes = new Node[cnt];
            for (int i = 0; i < cnt; i++)
            {
                nodes[i].left = -1;
                nodes[i].right = -1;
            }
            var preorder = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var inorder = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            GetTree(nodes, preorder, inorder, 0, cnt, 0);
            StringBuilder builder = new StringBuilder();
            PostOrder(builder, nodes, 0);
            Console.WriteLine(builder.ToString());
        }

        public static void GetTree(Node[] nodes, int[] preorder, int[] inorder, int from, int to, int index)
        {
            int value = preorder[index];
            nodes[index].value = value;
            int sep = from;
            for (int i = from; i < to; i++)
            {
                if (inorder[i] == value) sep = i;
            }
            if (sep != from)
            {
                nodes[index].left = index + 1;
                GetTree(nodes, preorder, inorder, from, sep, index + 1);
            }
            if (sep < to-1)
            {
                int gap = sep - from;
                nodes[index].right = index + 1 + gap;
                GetTree(nodes, preorder, inorder, sep + 1, to, index + gap + 1);
            }
            return;
        }
        public static void PostOrder(StringBuilder builder, Node[] nodes, int index)
        {
            if (nodes[index].left != -1)
                PostOrder(builder, nodes, nodes[index].left);
            if (nodes[index].right != -1)
                PostOrder(builder, nodes, nodes[index].right);
            if (index == 0)
                builder.Append(nodes[index].value);
            else builder.Append(nodes[index].value).Append(" ");
        }
    }
}

Measured memory_bytes: 9172
MOD=10**9+7
cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def desc(ar) ar.sort!{|x,y|y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end

def bs(ar,eq,n) en=(eq==1 ? :>= : :>); ar.bsearch_index{|x|x.send(en,n)} end
def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end

def puts_yesno(can) puts(can ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def debug(k,v) puts "#{k}:#{v}" end
########### ( ˘ω˘ )ｽﾔｧ… ###########
n=gi
t,a=gsmi
h=gsmi

min = 100000
min_i=1
n.times do |i|
  diff = (t-0.006*h[i]-a).abs
  if min>diff
    min=diff
    min_i=i+1
  end
end

puts min_i

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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

string f(string &s){
	map<char,char> g;
	for(char &c:s){
		if(g.count(c)==0) g[c]='A'+g.size();
		c=g[c];
	}
	return s;
}

int main(){
	string s,t; cin>>s>>t;
	cout<<(f(s)==f(t)?"Yes":"No")<<endl;
	return 0;
}


Measured memory_bytes: 1160
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define i_inf int(1e9)
#define i_half_inf int(1e5)
#define ll_inf ll(1e9)*ll(1e9)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const int mod = 1000000007;

string X;

void solve() {
    stack<char> s;
    rep(i, X.length()) {
        if (!s.empty() && s.top() == 'S' && X[i] == 'T') s.pop();
        else s.push(X[i]);
    }
    cout << s.size() << endl;
}

int main() {
    cin >> X;
    solve();
    return 0;
}

Measured memory_bytes: 644
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353


N, M = map(int, input().split())
A = list(map(int, input().split()))
A = list(map(lambda x: x*(-1), A))
heapq.heapify(A)

for i in range(M):
    a = heapq.heappop(A)
    a = ((-1) * a // 2) * (-1)
    heapq.heappush(A, a)

print(-sum(A))


Measured memory_bytes: 96660
nums = [None] * 5

n, m = map(int, input().split())
for _ in range(m):
    s, c = map(int, input().split())
    if s > n:
        print(-1)
        exit()
    if nums[s-1] is None or nums[s-1] == c:
        nums[s-1] = c
    else:
        print(-1)
        exit()

if n == 1:
    num = nums[0]
    if num is None:
        num = 0
    print(num)
    exit()

if nums[0] == 0:
    print(-1)
    exit()

res = []
if nums[0] is None:
    res.append(1)
else:
    res.append(nums[0])

for i in range(1, n):
    num = nums[i]
    if num is None:
        num = 0
    res.append(num)

print(*res, sep='')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double db;
#define endl '\n'
#define fi first
#define se second
#define pi pair<ll,ll>
#define pii pair<ll,pi>
#define pb push_back
#define mk make_pair
const ll siz = 1e5 + 7;
vector < pi> adj[siz];
ll n, k, q;
vector<ll>dis(siz, 1e15);
vector<bool>vis(siz, false);
void bfs(ll node) {
	dis[node] = 0;
	vis[node] = false;
	queue<ll>q;
	q.push(node);
	while (!q.empty()) {
		int v = q.front();
		q.pop();
		for (auto k : adj[v]) {
			if (!vis[k.fi]) {
				dis[k.fi] = min(dis[k.fi], k.se + dis[v]);
				vis[k.fi] = true;
				q.push(k.fi);
			}
		}
	}
}
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	for (ll i = 0; i < n - 1; i++) {
		ll u, v, len;
		cin >> u >> v >> len;
		--u, --v;
		adj[u].pb({v, len});
		adj[v].pb({u, len});
	}
	cin >> q >> k;
	--k;
	bfs(k);
	for (ll i = 0; i < q; i++) {
		ll x, y;
		cin >> x >> y;
		--x, --y;
		cout << abs(dis[x] - dis[k]) + abs(dis[y] - dis[k]) << endl;
	}
}

Measured memory_bytes: 11956
N=int(input())
ans = 'Yes'
pt,px,py=0,0,0
for i in range(N):
  t,x,y=map(int, input().split())
  fg = abs(t-pt)-(abs(x-px)+abs(y-py))
  if fg%2!=0 or fg<0:
    ans = 'No'
    break
  pt,px,py=t,x,y
print(ans)

Measured memory_bytes: 3060
#include<stdio.h>
int main() {
    int a,b,c;
    scanf("%d %d",&a,&b);
    if(a==1&&b==2)
    printf("3");
    else if(a==2&&b==1)
    printf("3");
    else if(a==1&&b==3)
    printf("2");
    else if(a==3&&b==1)
    printf("2");
    else if(a==2&&b==3)
    printf("1");
    else
    printf("1");
return 0;
}

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

int main(){
    ll n;
    cin >> n;
    ll b = 0;
    for(ll i = ll(pow(n, 0.5)); i > 0; i--){
        if(n%i == 0){
            b = n/i;
            break;
        }
    }
    int ans = 0;
    while(b > 0){
        b /= 10;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4032
N = int(input())
A = list(map(int,input().split()))
Q = int(input())
BC = [tuple(map(int,input().split())) for i in range(Q)]
from collections import Counter
ctr = Counter(A)
sm = sum(A)

ans = []
for b,c in BC:
    n = ctr[b]
    sm -= n * b
    sm += n * c
    ctr[b] -= n
    ctr[c] += n
    ans.append(sm)
print(*ans, sep='\n')

Measured memory_bytes: 39444
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
using namespace std;

int main() {
  int n;
  cin >> n;
  cout << 24+(24-n) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int ans,s=0,t=0;
    for(int i=0;i<4;++i){
        scanf("%d",&ans);
        s+=ans;
    }
    for(int i=0;i<4;++i){
        scanf("%d",&ans);
        t+=ans;
    }
    if(s >= t){
        printf("%d\n",s);
    }else if(s <= t){
        printf("%d\n",t);
    }
    return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;
#define int long long
#define pb push_back
#define pi pair <int, int> 

int n;
pi a[100100];
int32_t main() {
	cin >> n;
	for(int i = 0; i < n; ++i) {
		cin >> a[i].second;
		a[i].first = i+1;
	}
	sort(a, a+n, [](pi i, pi j) {
		return i.second < j.second;
	});
	for(int i = 0; i < n; ++i) {
		cout << a[i].first << ' ';
	}
}

Measured memory_bytes: 5104
#include<bits/stdc++.h>
long long f(long long n){
  if(n%2==0){
  	if((n/2)%2==0)return n;
    else return n+1;
  }else{
    if(((n+1)/2)%2==0)return 0;
  	else return 1;
  }
}
     
int main(){
  long long  a,b;scanf("%lld%lld",&a,&b);
  printf("%lld",f(a-1)^f(b));
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

const int BIT_SIZE = 40;

ll f(ll a) {
    bitset<BIT_SIZE> bit;
    
    if (a < 0) {
        return 0;
    }
    
    for (ll i = 0; i < BIT_SIZE; i++) {
        ll loop_size = 1LL << (i + 1);
        ll cnt = (a / loop_size) * (loop_size / 2);
        cnt += max(0LL, (a % loop_size) - (loop_size / 2) + 1);
        bit[i] = (cnt % 2 == 1);
    }
    
    return bit.to_ullong();
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll a, b;
    cin >> a >> b;
    cout << (f(b) ^ f(a - 1)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-8;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

int main() {
    ll n, x, len[55], b[55], ans=0, k;
    cin >> n >> x;

    // レベル毎のバーガーの長さとパティの数を前計算
    len[0] = 1;
    b[0] = 1;
    REP(i,n){
        len[i+1] = len[i]*2+3;
        b[i+1] = b[i]*2+1;
    }
    
    k = n;
    while(x>0){
        if(x>=len[k]){ // レベルk分食べる
            ans += b[k];
            x -= len[k];
            if(x>0){
                ans++;
                x--;
            }
        }
        else{
            k--;
            x--;
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}


string Itoa(int n)
{
	string ret;;
	char moji = 'a';

	while (n >=27) {
		if (n % 26 == 0) {
			ret += moji + 25;
			n =n- 26;
		}
		else {
			ret += moji + n % 26 - 1;
		}
		n /= 26;
	}
	if (n > 0) {
		ret += moji + n-1;
	}
	// 文字列の順番を逆にする
	std::reverse(ret.begin(), ret.end());

	return ret;
}


signed main(void) {
	int n;
	cin >> n;
	print(Itoa(n));
}

Measured memory_bytes: 3568
S=list(input())
Check_list=['A','T','G','C']
 
out_num=0
for i in range(len(S)):
  for l in range(i,len(S)): 
    
    c=[x for x in S[i:l+1] if x not in Check_list]
    
    if (len(c) == 0) & (len(S[i:l+1]) >= out_num):
      out_num=len(S[i:l+1])
       
print(out_num)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;


int main(){
  int a, p;
  cin>>a>>p;

  p += a*3;
  cout<<(p/2)<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")


void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll mod(ll n){return n%=MOD1;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}


int main(void){
    char s[105][105];
    ll h,w;
    scanf("%lld%lld",&h,&w);
    // ll [n];
    rep(i,0,h){
        scanf("%s",s[i]);
    }
    ll dp[100][100],dx[2]={1,0},dy[2]={0,1};
    rep(i,0,h) rep(j,0,w) dp[i][j]=INF;
    
    rep(i,0,h){
        rep(j,0,w){
            if(i==0&&j==0){
                dp[i][j]= s[0][0]=='.'?0:1;
            }
            rep(k,0,2){
                ll X=j+dx[k],Y=i+dy[k];
                if( X<w && Y<h ){
                    if(s[Y][X]=='.'){
                        dp[Y][X]=min2(dp[Y][X],dp[i][j]);
                    }else{
                        if(s[i][j]=='#'){
                            dp[Y][X]=min2(dp[Y][X],dp[i][j]);
                        }else{
                            dp[Y][X]=min2(dp[Y][X],dp[i][j]+1);
                        }
                    }
                }
            }
            // rep(k,0,h){
            //     rep(l,0,w) printf("%lld ",dp[k][l]);
            //     PN;    
            // }
            // PN;
        }
    }
    
    printf("%lld\n",dp[h-1][w-1]);
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N, = map(int, input().split())
L = [int(v) for v in input().split()]

for i in range(1, N):
    a, b = L[i - 1], L[i]
    
    if a < b:
        L[i] -= 1
        
ans = True
for i in range(1, N):
    a, b = L[i - 1], L[i]
    
    if a > b:
        ans = False
        break
    
if ans:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

constexpr int nlim = 1e2, klim = 1e5;
int dp[2][klim+1];

int main(){
  int n, k; cin >> n >> k;
  int a[n];
  REP(i, n) cin >> a[i];

  memset(dp, -1, sizeof(dp));

  dp[0][0] = 0; dp[1][0] = 0;

  REP(rest, k+1)REP(turn, 2){
    dp[turn][rest] = 0;
    REP(i, n){
      if(rest - a[i] < 0) continue;
      dp[turn][rest] |= !dp[1-turn][rest-a[i]];
    }
  }
  
  string ans = (dp[0][k])? "First": "Second";
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>

int main(){

int counter=0,max=0;
char S[10];
scanf("%s",S);

for (int i = 0; i < 10; i++)
{
  while (S[i]=='A'||S[i]=='C'||S[i]=='G'||S[i]=='T')
  {
    counter++;
    if (max<counter) max = counter;
    i++;
  }
  counter=0;
}
printf("%d",max);
  
return 0;
}


Measured memory_bytes: 1728
#include <stdio.h>

#define MIN(a, b) ((a) < (b) ? (a) : (b)) //小さい方の数字を返す
#define PI 3.14159265358979323846

int main()
{
  int num, i;
  int tmp[3];
  char output[6] = "ABC";

  scanf("%d", &num);

  tmp[0] = num / 100;
  num %= 100;
  tmp[1] = num / 10;
  num %= 10;
  tmp[2] = num;

  for(i = 3; i < 6; i++){
    output[i] = tmp[i-3] + '0';
  }

  printf("%s\n", output);

  return 0;
}
  


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <boost/multiprecision/cpp_int.hpp>

static const int INF = 1000000007;
using ll = long long;
using namespace std;
using bigint = boost::multiprecision::cpp_int;

bigint lcm(bigint a, bigint b){
    bigint v = a * b / __gcd(a, b);
    return v;
}

int main() {
    int n;
    bigint ans;
    cin >> n;
    cin >> ans;
    for (int i = 0; i < n - 1; ++i) {
        ll k;
        cin >> k;
        ans = lcm(ans , k);
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <map>
#include <algorithm>
#define fr first
#define sc second
#define INF (2 << 28)
using namespace std;

typedef pair<int,int> iP;
iP dat[3];

double dp[5001];

double rec(int sum){
  if(sum == 0) return 0;
  if(sum < 0) return INF;
  if(dp[sum]) return dp[sum];
  double ret = INF;

  ret = min(rec(sum - 200 * 5) + 380 * 5 * 0.8,ret);
  ret = min(rec(sum - 300 * 4) + 550 * 4 * 0.85,ret);
  ret = min(rec(sum - 500 * 3) + 850 * 3 * 0.88,ret);
  
  for(int i=0;i<3;i++)
    ret = min(rec(sum - dat[i].fr) + dat[i].sc,ret);
  

  return dp[sum] = ret;
}

int main(){
  int n;
  dat[0].fr = 200; dat[0].sc = 380;
  dat[1].fr = 300; dat[1].sc = 550;
  dat[2].fr = 500; dat[2].sc = 850;

  while(cin >> n,n){
    memset(dp,0,sizeof(dp));
    cout << rec(n) << endl;
  }
}

    

Measured memory_bytes: 1272
n=int(input())
mns=list(map(int,input().split()))
hrs=list(map(int,input().split()))
mk=0
for i in range(n):
  if(hrs[i]>=mns[i]+mns[i+1]):
    mk+=mns[i]+mns[i+1]
    mns[i]=0
    mns[i+1]=0
  else:
    if(hrs[i]<=mns[i]):
      mk+=hrs[i]
    else:
      mk+=hrs[i]
      mns[i+1]-=(hrs[i]-mns[i])
print(mk)


Measured memory_bytes: 18396
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	string s;
	cin>>s;
	int g=0,l=s.length();
	FOR(i,0,l){
		if(s[i]=='g')g++;
	}
	cout<<l/2-l+g<<endl;
    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
int main() {
   int N;
   cin >> N;
   vector<ll> A(N);
 
   __int128 ans = 1;
 
   for(int i=0;i<N; i++) {
      cin >> A[i];
      if(A[i] == 0) {
         cout << 0 << endl;
         return 0;
      }
   }
 
   for(int i=0; i<N; i++) {
      ans *= A[i];
      if(ans > 1000000000000000000) {
         cout << -1 << endl;
         return 0;
      }
   }
   cout << (ll)ans << endl;
}

Measured memory_bytes: 3976
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1LL << 60;
int main(){
    int n,k; cin >> n >> k;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    int ans = 0;
    rep(i,n){
        if(h[i]>=k) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
    int mini,last,i,a[10],sum=0;
    mini=10;last=0;
    for(i=0;i<5;i++)
    {scanf("%d",&a[i]);
    if(a[i]%10<mini&&a[i]%10!=0)
    {
        mini=a[i]%10;
        last=i;
    }
    sum+=(a[i]/10)*10;
    if(a[i]%10!=0)
        sum+=10;
    }
    if(mini!=10)
    {
        sum-=10-a[last]%10;
    }
    printf("%d",sum);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
string s[200005];
int main(void)
{
    int n,cnt=0;
    cin >> n;
    for(int i=1;i<=n;i++) cin >> s[i];
    sort(s+1,s+n+1);
    for(int i=1;i<=n;i++)
        if(s[i]!=s[i-1])
            cnt++;
    cout << cnt;
    return 0;
}


Measured memory_bytes: 9892
import java.util.*;
import java.io.*;
import java.math.*;

public class Main{



  public static OutputStream out=new BufferedOutputStream(System.out);
  static Scanner sc=new Scanner(System.in);
  static long MOD=1000000007l;
  static int INF=10000000;
  static int[] rr=new int[]{1, 0, -1, 0};                                 //rook row move
  static int[] rc=new int[]{0, 1, 0, -1};                                 //rook col move

  //nl-->neew line; //l-->line;  //arp-->array print;  //arpnl-->array print new line
  public static void nl(Object o) throws IOException{out.write((o+"\n").getBytes()); }
  public static void l(Object o) throws IOException{out.write((o+"").getBytes());}
  public static void arp(int[] o) throws IOException{for(int i=0;i<o.length;i++) out.write((o[i]+" ").getBytes()); out.write(("\n").getBytes());}
  public static void arpnl(int[] o) throws IOException{for(int i=0;i<o.length;i++) out.write((o[i]+"\n").getBytes());}
  public static void scanl(long[] a,int n) {for(int i=0;i<n;i++) a[i]=sc.nextLong();}
  public static void scani(int[] a,int n) {for(int i=0;i<n;i++) a[i]=sc.nextInt();}
  public static void scan2D(int[][] a,int n,int m) {for(int i=0;i<n;i++) for(int j=0;j<m;j++) a[i][j]=sc.nextInt();}
  //static variables

  //


  public static void main(String[] args) throws IOException{
    long sttm=System.currentTimeMillis();
    long mod=1000000007l;

    // int k=sc.nextInt();
    int k=1;
    while(k-->0){
        solve();
    }

    out.flush();
  }

  public static void solve() throws IOException{
      int n=sc.nextInt();
      int[][] a=new int[n][2];
      int cnt=0;
      boolean con=false;
      for(int i=0;i<n;i++){
          a[i][0]=sc.nextInt(); a[i][1]=sc.nextInt();
          if(a[i][0]==a[i][1]){
              cnt++;
          }
          else{
              cnt=0;
          }
          if(cnt==3){
              con=true;
              // break;
          }
      }
      if(con){
          nl("Yes");
      }
      else nl("No");
  }

}

class Pair{
  int x; int y;
  Pair(int x,int y){
    this.x=x;
    this.y=y;
  }
}


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

using namespace std;

int main(){

  vector<int> w(10);
  vector<int> k(10);
  int w1=0;
  int w2=0;
  int w3=0;
  int k1=0;
  int k2=0;
  int k3=0;
  
  for(int i=0;i<10;++i)
	cin>>w[i];

  for(int i=0;i<10;++i)
	cin>>k[i];

  int temp;
  for(int i=0;i<10;++i){
	if(w1<w[i]){
	  w1=w[i];
	  temp=i;
	}
  }

  w[temp]=0;
  for(int i=0;i<10;++i){
	if(w2<w[i]){
	  w2=w[i];
	  temp=i;
	}
  }

  w[temp]=0;
  for(int i=0;i<10;++i){
	if(w3<w[i]){
	  w3=w[i];
	  temp=i;
	}
  }

  

  for(int i=0;i<10;++i){
	if(k1<k[i]){
	  k1=k[i];
	  temp=i;
	}
  }

  k[temp]=0;
  for(int i=0;i<10;++i){
	if(k2<k[i]){
	  k2=k[i];
	  temp=i;
	}
  }

  k[temp]=0;
  for(int i=0;i<10;++i){
	if(k3<k[i]){
	  k3=k[i];
	  temp=i;
	}
  }
  
  cout<<w1+w2+w3<<" "<<k1+k2+k3<<endl;

  return 0;
  
}



Measured memory_bytes: 3092
#include<stdio.h>
//#include<conio.h>
int main(){
  int A1;
  int A2;
  int A3;
  int result;
  scanf("%d",&A1);
  scanf("%d",&A2);
  scanf("%d",&A3);
  if(A1>=1&&A1<=13)
  	if(A2>=1&&A2<=13)
    	if(A3>=1&&A3<=13)
     		 result=A1+A2+A3;
    	 		if(result>=22)
  					printf("bust");
  				else 
   					printf("win");
 return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <set>
#include <math.h>
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
typedef long long ll;
using namespace std;

const int64_t INF=1000000000000000000;

int main() {
    int n;
    cin >> n;
    int64_t sum=1;
    bool flag = false;
    vector<int64_t> a(n);
    rep(i,0,n) {
        ll a;
        cin >> a;
        if(a==0) {
            cout << 0 << endl;
            return 0;
        }
        if(flag||__int128(sum)*a>INF) {
            flag=true;
        }
        sum*=a;
    }
    if (flag) cout << -1 << endl;
    else cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3668
from itertools import combinations
n = int(input())
primes = []
for num in range(2, 55556):
    for prime in primes:
        if num % prime == 0:
            break
    else:
        primes.append(num)

primes_mod1 = []
for prime in primes:
    if prime % 5 == 1:
        primes_mod1.append(prime)
print(*primes_mod1[:n], sep=" ")

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

int main(){
    int n,r;
    cin >> n >> r;
    int ans=0;
    if(n>=10) ans=r;
    else ans=r+100*(10-n);
    cout << ans << endl;
}


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()
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n;
	cin >> n;

	vector<int> v(n);
	rep(i, n) cin >> v[i];

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

	ll ans = 0;
	for(int i = 0; i < n; i++){
		for(int j = i + 1; j < n; j++){
			int l = v[i] + v[j];

			auto itr = lower_bound(v.begin(), v.end(), l);
			int num = distance(v.begin(), itr) - j - 1;

			// cout << i << "," << j << "," << l << "," << num << endl;
			ans += num;
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a1, a2, a3;
  cin >> a1 >> a2 >> a3;
  if (a1+a2+a3 <= 21)
    cout << "win" << endl;
  else
    cout << "bust" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1LL<<60;
const int MOD = (int)1e9 + 7;


struct UnionFind {
    vector<int> _parent;
    vector<int> _size;

    explicit UnionFind(int n) : _parent(n), _size(n, 1LL) {
        for (int i = 0; i < n; i++)
            _parent[i] = i;
    }

    int root(int x) {
        if (_parent[x] == x)
            return x;
        return _parent[x] = root(_parent[x]);
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry)
            return;
        if (size(rx) < size(ry))
            swap(rx, ry);
        _parent[ry] = rx;
        _size[rx] += _size[ry];
    }

    int size(int x) {
        return _size[root(x)];
    }
};

signed main() {
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> v;
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        v.emplace_back(a - 1, b - 1);
    }
    reverse(v.begin(), v.end());
    UnionFind tree(n);
    vector<int> ans(m);
    ans[0] = n * (n - 1) / 2;
    for (int i = 1; i < m; i++) {
        int x = v[i - 1].first;
        int y = v[i - 1].second;
        if (tree.same(x, y)) {
            ans[i] = ans[i - 1];
        }
        else {
            ans[i] = ans[i - 1] - tree.size(x) * tree.size(y);
        }
        tree.unite(x, y);
    }
    reverse(ans.begin(), ans.end());
    for_each(ans.begin(), ans.end(), [](int x) {
        cout << x << "\n";
    });
}

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

using namespace std;
typedef long long ll;

const int MAXN = 100005;

int n, e, T;
int x[MAXN];

void input()
{
	scanf("%d%d%d", &n, &e, &T);
	for(int i = 1; i <= n; i++)
		scanf("%d", &x[i]);
}

ll f[MAXN];

void solve()
{
	f[0] = 0;
	ll minv = 1e18;
	int j = 0;
	for(int i = 1; i <= n; i++)
	{
		f[i] = f[i - 1] + T;
		while(2 * (x[i] - x[j + 1]) > T)
		{
			minv = min(minv, f[j] - 2 * x[j + 1]);
			j++;
		}
		f[i] = min(f[i], f[j] + T);
		f[i] = min(f[i], minv + 2 * x[i]);
	}
}

void output()
{
	printf("%lld\n", f[n] + e);
}

int main()
{
	input();
	solve();
	output();

	return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<string>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
typedef long long ll;

int main(){
    int N;
    string s;
    string ans;
    cin >> N; 
    cin >> s;
    string s0 = "SSWW";
    string s1 = "SWSW";
    bool check1=false;
    bool check2=false;
    for(int i=0; i<4; i++){
        ans.clear();
        ans.push_back(s0[i]);
        ans.push_back(s1[i]);
        for(int j=1; j<N-1; j++){
            if(ans[j]=='S'){
                if(s[j]=='o'){
                    ans.push_back(ans[j-1]);
                }else{
                    if(ans[j-1]=='S'){
                        ans.push_back('W');
                    }else{
                        ans.push_back('S');
                    }
                }
            }else{
                if(s[j]=='x'){
                    ans.push_back(ans[j-1]);
                }else{
                    if(ans[j-1]=='S'){
                        ans.push_back('W');
                    }else{
                        ans.push_back('S');
                    }
                }
            }
        }
        //cout << ans << endl;
        if(s[N-1]=='o' && ans[N-1]=='S' && ans[N-2]==ans[0]){
            check1 = true;
        }
        if(s[N-1]=='o' && ans[N-1]=='W' && ans[N-2]!=ans[0]){
            check1 = true;
        }
        if(s[N-1]=='x' && ans[N-1]=='W' && ans[N-2]==ans[0]){
            check1 = true;
        }
        if(s[N-1]=='x' && ans[N-1]=='S' && ans[N-2]!=ans[0]){
            check1 = true;
        }
        if(s[0]=='o' && ans[0]=='S' && ans[N-1]==ans[1]){
            check2 = true;
        }
        if(s[0]=='o' && ans[0]=='W' && ans[N-1]!=ans[1]){
            check2 = true;
        }
        if(s[0]=='x' && ans[0]=='W' && ans[N-1]==ans[1]){
            check2 = true;
        }
        if(s[0]=='x' && ans[0]=='S' && ans[N-1]!=ans[1]){
            check2 = true;
        }
        if(check1 && check2){
            break;
        }else
        {
            check1=false;
            check2=false;
        }
        
    }
    if(check1 && check2){
        cout << ans << endl;
    }else{
        cout << "-1" << endl;
    }
    
    return 0;
}

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

int main()
{
    int H, W;
    cin >> H >> W;
    vector<vector<char>> A(H, vector<char>(W));
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            cin >> A.at(i).at(j);
        }
    }
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            if (A.at(i).at(j) == '#')
            {
                cout << '#';
            }
            else
            {
                int count = 0;
                for (int k = i - 1; k <= i + 1; k++)
                {
                    if (k >= 0 && k < H)
                    {
                        for (int l = j - 1; l <= j + 1; l++)
                        {
                            if (l >= 0 && l < W)
                            {
                                if (A.at(k).at(l) == '#')
                                {
                                    count++;
                                }
                            }
                        }
                    }
                }
                cout << count;
            }
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
class Rename
  def initialize year, name
    @year = year
    @name = name
  end
  attr_reader :year, :name
end

def main
  n,q = gets.chomp.split.map(&:to_i)
  histry = []
  histry << Rename.new(0, 'kogakubu10gokan')
  n.times do
    year_str,name = gets.chomp.split
    histry << Rename.new(year_str.to_i, name)
  end
  puts get_name(histry, q)
end

def get_name histry, year
  answer = ''
  histry.each do |rename|
    if rename.year == year
      answer = rename.name
      break
    elsif rename.year < year
      answer = rename.name
    else
      break
    end
  end
  answer
end

main

Measured memory_bytes: 6108
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long
#define pb push_back
#define ff first
#define ss second
#define BS binary_search
#define m 1000000007

const long long INF=1e18;

template <class A, class B> ostream& operator<<(ostream& os, const pair<A,B> p) {return os << "(" << p.first << "," << p.second << ")";} 

void dprint(string s) {cout << endl;}
template <class T, class... U> void dprint(string s, T t, U... u) 
{int w = s.find(','); cout << "[" << s.substr(0,w) << ": " << t << "] "; dprint(s.substr(w+1, (int)s.size()-w), u...);} 

#define DEBUG 
#ifdef DEBUG
#define dbg(X...) dprint(#X,X)
#else
#define dbg(X...) "KEEP CALM" 
#endif

const int N=100005; // Don't forget to CHANGE this value ACC. TO Q.
long long moduloMultiplication(long long a, 
                            long long b, 
                            long long mod) 
{ 
    long long res = 0; // Initialize result 
  
    // Update a if it is more than 
    // or equal to mod 
    a %= mod; 
  
    while (b) 
    { 
        // If b is odd, add a with result 
        if (b & 1) 
            res = (res + a) % mod; 
  
        // Here we assume that doing 2*a 
        // doesn't cause overflow 
        a = (2 * a) % mod; 
  
        b >>= 1; // b = b / 2 
    } 
  
    return res; 
} 
int32_t main()
{
    IOS;
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int T=1; 
    //cin>>T;
    while(T--)
    {
        int n;cin>>n;
        int a[n+1];
        int pref[n+1];
        a[0]=0;
        for(int i=1;i<=n;i++)
            cin>>a[i];
        pref[1]=a[1];
        for(int i=2;i<=n;i++){
            pref[i]=pref[i-1]+a[i];
        }
        int ans=0;
        for(int i=2;i<=n;i++){
            ans+=moduloMultiplication(a[i],pref[i-1],m);
            ans=(ans+m)%m;
        }
        cout<<(ans+m)%m;
    }
    return 0;
}

Measured memory_bytes: 6700
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
int main()
{
    int n;
    scanf("%d", &n);
    double ans = 0;
    rep(i, n) {
        double x; string u;
        cin >> x >> u;
        if(u == "JPY") ans += x;
        else ans += x * 380000;
    }
    printf("%lf\n", ans);
    return 0;
}

Measured memory_bytes: 3824
class InputLine
  def self.to_s
    gets.chomp
  end

  def self.to_i
    InputLine.to_s.to_i
  end
  
  def self.to_f
    InputLine.to_s.to_f
  end

  def self.to_sa
    InputLine.to_s.split(' ')
  end

  def self.to_ia
    InputLine.to_sa.map(&:to_i)
  end
  
  def self.to_fa
    InputLine.to_sa.map(&:to_f)
  end
end

def main(argv)
  s = InputLine.to_s
  if 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.include?(s[0]) then
    puts 'A'
  else
    puts 'a'
  end
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 14352
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H,W;
  cin >> H >> W;
  string P,P2;
  
  for(int i = 0; i < H; i++){
    cin >> P2;
    P += P2;
  }
  
  for(int i = 0; i < (H+2); i++){
    if(i == 0 || i == (H+1)){
      for(int j = 0; j < (W+2); j++){
        cout << '#';
      }
    }else{
      cout << '#';
      for(int j = 0;j < W; j++){
        cout << P.at(j+(i-1)*W);
      }
      cout << '#';
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
N,M=[int(i) for i in input().split()]
a=[int(input()) for _ in range(M)]

b=[0]*(N+2)
b[0]=1
b[1]=1

for j in range(M):
    b[a[j]]=-1

for i in range(2,N+2):
    if b[i] !=-1:
        if b[i-1]!=-1:
            b[i]+=b[i-1]
        if b[i-2]!=-1:
            b[i]+=b[i-2]
print(b[-2]%(1000000007))

Measured memory_bytes: 462708
// D.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

int main(int argc, char *argv[]) {
	string s;
	cin >> s;
	int len = (int)s.length();
	s += 'R';
	vector<int> elements, count(len);
	char prev = -1;
	int pos = -1;
	for (int i = 0; i <= len; ++i) {
		if (s[i] == 'R') {
			if (prev == 'L') {
				for (int x : elements) {
					count[pos + (abs(pos - x) % 2)] += 1;
				}
				elements.clear();
			}
			pos = i;
		}
		elements.push_back(i);
		prev = s[i];
	}
	for (int i = 0; i < len; ++i) {
		if (i) cout << " ";
		cout << count[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 1528
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String []args)throws Exception
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw=new BufferedWriter(new OutputStreamWriter(System.out));
        int n=Integer.parseInt(br.readLine());
        int A[]=new int[n];
        int B[]=new int[n];
        int C[]=new int[n];
        int x[]=Arrays.stream(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
        A[0]=x[0];
        B[0]=x[1];
        C[0]=x[2];
        for(int i=1;i<n;i++)
        {
            int abc[]=Arrays.stream(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
            A[i]=Math.max(B[i-1],C[i-1])+abc[0];
            B[i]=Math.max(A[i-1],C[i-1])+abc[1];
            C[i]=Math.max(A[i-1],B[i-1])+abc[2];
        }
        bw.write(Integer.toString(Math.max(A[n-1],Math.max(B[n-1],C[n-1]))));
        br.close();
        bw.close();
    }
}

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


int main(){
    int N,M;
    cin >> N >> M;
    bool F[N] = {};
    int C[N] = {};
    rep(i,N) C[i] = 1;
    F[0] = 1;
    rep(i,M){
        int x,y;
        cin >> x >> y;
        x--,y--;
        if(F[x]){
            F[y] = true;
        }
        C[x]--;
        C[y]++;
        if(C[x] == 0) F[x] = false;
    }
    long long res = 0;
    rep(i,N) if(F[i]) res++;
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c;
  int cnt = 0;
  cin >> a >> b >> c;
  if(a==b){
    cnt = cnt + 1;
  }
  if(a==c){
    cnt = cnt + 1;
  }
  if(b==c){
    cnt = cnt + 1;
  }
  if(cnt==1){
    cout <<"Yes";
  } else {
    cout<<"No";
  }
  return 0;
}

Measured memory_bytes: 384