akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
long long int dp[100000][2];
int func(long long int index,long long int color,vector<long long int> adj[],long long int p)
{
    if(dp[index][color]!=-1)
    {
        return dp[index][color]%mod;
    }
    long long int count=1;
    for(auto it=adj[index].begin();it!=adj[index].end();it++)
    {
        if(*it!=p)
        {
            if(color==0)
            {
                count=((count%mod)*(func(*it,0,adj,index)%mod+func(*it,1,adj,index)%mod)%mod)%mod;
            }
            else
            {
                count=((count%mod)*(func(*it,0,adj,index)%mod))%mod;
            }
        }
    }
    dp[index][color]=count%mod;
    return dp[index][color]%mod;
}
int main() 
{
	long long int n;cin>>n;
	vector<long long int> adj[n];
	memset(dp,-1,sizeof(dp));
	for(long long int i=0;i<n-1;i++)
	{
	    long long int src,des;cin>>src>>des;
	    src--;des--;
	    adj[src].push_back(des);
	    adj[des].push_back(src);
	}
	long long int count=(func(0,0,adj,-1)%mod+func(0,1,adj,-1)%mod)%mod;
	cout<<count;
	
}

Measured memory_bytes: 14208
from heapq import heappush,heappop
import queue
import re
import math
import functools

def int_raw():
    return int(input())

def ss_raw():
    return input().split()

def ints_raw():
    return list(map(int, ss_raw()))

INF = 1<<29

def make1d_arr(n,val=INF):
    return [val for i in range(n)]

def make2d_arr(h,w,val =INF):
    return [[val for i in range(w)]for i in range(h)]


N = int_raw()
A = ints_raw()


def main():
    numNega = len([a for a in A if a<0])
    numZero = len([a for a in A if a==0])
    absA = list(map(abs,A))
    if numZero >1 or numNega%2 == 0:
        return sum(absA)
    else:
        minAbs = min(absA)
        return sum(absA)-minAbs*2

print(main())


Measured memory_bytes: 15996
#include<stdio.h>
#include<string.h>
int main(void){
char S[20], T[20], U[20];
int A=0, B=0, n=0, sum=0;
scanf("%s%s", S, T);
scanf("%d%d", &A, &B);
scanf("%s", U);
n=strlen(U);
for(int i=0;i<n;i++){
if(U[i]==S[i]){
    sum+=1;
}
}
if(sum==n){
printf("%d %d\n",A-1, B);
}else{
printf("%d %d\n",A, B-1);  
}
return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long H;
  int N;
  cin >> H >> N;
  
  int sum = 0;
  vector<int> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
    sum += vec.at(i);
  }
  if(H<=sum){
    cout << "Yes";
  }
  else{
    cout << "No";
  }
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int N, s = 0;
    cin >> N;
    vector<int> L(2 * N);
    for(int i = 0; i < 2 * N; i++)
    {
        cin >> L[i];
    }
    sort(L.begin(),L.end());
    for(int i = 0; i < 2 * N; i += 2)
    {
        s += L[i];
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*; 

class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
        long a=sc.nextLong();
  		long ans=1;
        long c=1;
		while(a>1){
        	a=a/2;
            ans+=Math.pow(2,c);
            c++;
        }

    	System.out.println(ans);
    }
}

Measured memory_bytes: 23380
fun main(args: Array<String>) {
    abc070d()
}

private data class Edge(val from: Int, val to: Int, val cost: Long)

fun abc070d() {
    val n = readLine()!!.toInt()
    val abcList = (1 until n)
        .map { readLine()!!.split(' ').map { it.toInt() }.let { Edge(it[0] - 1, it[1] - 1, it[2].toLong()) } }
    val (q, k) = readLine()!!.split(' ').map { it.toInt() }
    val queries = (1..q)
        .map { readLine()!!.split(' ').map { it.toInt() }.let { it[0] - 1 to it[1] - 1 } }

    // [from] = to, cost
    val graph = Array(n) { mutableListOf<Pair<Int, Long>>() }
    abcList.forEach {
        val (from, to, cost) = it
        graph[from].add(to to cost)
        graph[to].add(from to cost)
    }

    // cost from K
    val costs = LongArray(n) { -1 }

    fun dfs(beforeIndex: Int, beforeCost: Long, currIndex: Int, currCost: Long) {
        costs[currIndex] = beforeCost + currCost

        graph[currIndex].filter { costs[it.first] == -1L }.forEach {
            val (nextIndex, nextCost) = it
            dfs(currIndex, costs[currIndex], nextIndex, nextCost)
        }
    }

    dfs(-1, 0, k - 1, 0)

    val answer = queries.map { costs[it.first] + costs[it.second] }.joinToString(System.lineSeparator())

    println(answer)
}


Measured memory_bytes: 131928
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
	"strconv"
)

type intHeap []int

func (h intHeap) Len() int           { return len(h) }
func (h intHeap) Swap(i, j int)      { h[i], h[j] = h[j], h[i] }
func (h intHeap) Less(i, j int) bool { return h[i] > h[j] }
func (h intHeap) Push(x interface{}) { h = append(h, x.(int)) }
func (h intHeap) Pop() interface{} {
	old := h
	n := len(old)
	x := old[n-1]
	h = old[0 : n-1]
	return x
}

func solve() {
	n, m := getInt(), getInt()
	h := intHeap(getIntSlice(n))
	heap.Init(h)

	for i := 0; i < m; i++ {
		h[0] /= 2
		heap.Fix(h, 0)
	}

	ans := sum(h...)
	fmt.Fprintln(wr, ans)
}

func sum(ns ...int) int {
	var sum int
	for _, n := range ns {
		sum += n
	}
	return sum
}

// -----------------------------------------

const (
	inf = 1 << 60
	// mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}

func getRunes() []rune {
	return []rune(getString())
}


Measured memory_bytes: 4736
#include<iostream>
//#include<cstdlib>
#include<stack>
using namespace std;

int main()
{
  stack<int> S;
  int a, b, x;
  string s;

  while(cin >> s)
  {
    if(s[0] == '+')
    {
      a = S.top(); S.pop();
      b = S.top(); S.pop();
      S.push(a+b);
    }
    else if(s[0] == '-')
    {
      b = S.top(); S.pop();
      a = S.top(); S.pop();
      S.push(a-b);
    }
    else if(s[0] == '*')
    {
      a = S.top(); S.pop();
      b = S.top(); S.pop();
      S.push(a*b);
    }
    else S.push(stoi(s));
  }
  cout << S.top() << endl;

  return 0;
}



Measured memory_bytes: 3176
_n = gets.to_i
stones = gets.chomp.split("")
left_black = 0 # indexよりも左にある # の数
right_white = stones.count(".") # indexよりも右にある . の数
count = [left_black + right_white] # 数の合計
stones.each.with_index do |stone, i|
  if stone == "."
    right_white -= 1
  else # stone == "#"
    left_black += 1
  end
  count << left_black + right_white
end
puts count.min


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

typedef long long ll;
typedef pair<int, int> pii;

int n, k;
ll a[100];
ll ans = 1e18;
void dfs(int cur, ll hight, ll cost, int used) {
    if (used == k) {
        ans = min(ans, cost);
        return;
    }
    if (cur ==  n) {
        return ;
    }
    ll h;
    ll add = 0;
    if (a[cur] > hight) {
        h = a[cur];
    } else {
        h = hight + 1;
        add = h - a[cur];
    }
    
    hight = max(hight, a[cur]);
    dfs(cur + 1, h, cost + add, used + 1);
    dfs(cur + 1, hight, cost, used);
}

int main() {
    cin >> n >> k;
    
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    
    dfs(1, a[0], 0, 1);
    cout << ans << endl;
    
    return 0;
}

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

// boost
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

ld calc(ll v) {
  ll sum = 0;
  ll tmp = v;
  while (tmp) {
    sum += tmp % 10;
    tmp /= 10;
  }
  return (ld)v / (ld)sum;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll k;
  cin >> k;

  const ld eps = 1e-16;

  vll ans;
  ans.push_back(1e15 - 1);
  ld mn = calc(1e15 - 1);
  ll v = 1e15 - 1;
  while (v) {
    ll keta = 1;
    while (keta * 1000 < v) {
      keta *= 10;
    }
    v -= keta;
    if (v == 0)
      break;
    ld c = calc(v);
    if (c <= mn + eps) {
      mn = c;
      ans.push_back(v);
    }
  }

  reverse(all(ans));
  rep(i, k) {
    cout << ans[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 3512
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

int main(){
  int n, m;

  cin >> n >> m;

  int ans = 1;

  for(int i=1;i*i<=m;i++){
    if (m % i == 0) {
      if (i >= n)
        ans = max(ans, m / i);
      if (m/i >= n)
        ans = max(ans, i);
    }
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr)
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define REP(n) FOR(O, 1, (n))
#define pb push_back
#define f first
#define s second
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<piii> viii;
typedef pair<ll, ll> pl;
typedef pair<pl, pl> pll;

const int MAXN = 500100, MAXK = 35;
const ll MOD = 1e9+7;
const ll INF = 1e18;
const ld PI = asin(1) * 2;

/*
int par[MAXN];
int find(int a) {
    return par[a] = par[a]==a ? a : find(par[a]);
}
bool same (int a, int b) {
    return find(a)==find(b);
}
void unite(int a, int b) {
    a = find(a), b = find(b);
    if (a == b) return;
    par[b] = a;
}*/

/*int n, q;
pll tree[4*MAXN];
bool lazy[4*MAXN];
string s;

void upd (int id) {
    pl a1 = tree[2*id].f, b1 = tree[2*id].s;
    pl a2 = tree[2*id+1].f, b2 = tree[2*id+1].s;
    pl newA, newB;
    newA.f = a2.f*a1.f + a2.s*b1.f;
    newA.s = a2.f*a1.s + a2.s*b1.s;
    newB.f = b2.f*a1.f + b2.s*b1.f;
    newB.s = b2.f*a1.s + b2.s*b1.s;
    tree[id] = {newA, newB};
}

void build (int id = 1, int l = 0, int r = n-1) {
    if (l == r) {
        if (s[l] == 'A') {
            tree[id].f = {1, 1};
            tree[id].s = {0, 1};
        } else {
            tree[id].f = {1, 0};
            tree[id].s = {1, 1};
        }
        return;
    }
    int mid = (l+r)/2;
    build(2*id, l, mid);
    build(2*id+1, mid+1, r);
    upd(id);
}

void shift (int id, int l, int r) {}

ll f (int x, int y, ll a, ll b, int id = 1, int l = 0, int r = n-1)
*/

vl a, f;

int main ()
{
    FAST_IO;

    int n; ll k;
    cin >> n >> k;
    REP(n) {ll x; cin >> x; a.pb(x);}
    REP(n) {ll x; cin >> x; f.pb(x);}
    sort(a.begin(), a.end());
    sort(f.begin(), f.end());
    reverse(a.begin(), a.end());

    ll le = 0, ri = 1e15;
    while (le < ri) {
        ll mid = (le+ri)/2;

        ll req = 0;
        FOR(i, 0, n-1) {
            if (a[i]*f[i] <= mid) continue;
            req += (a[i]*f[i]-mid+f[i]-1)/f[i];
        }

        if (req <= k) ri = mid;
        else le = mid+1;

    }

    cout << le;

    return 0;
}


Measured memory_bytes: 4848
#include <stdio.h>

int main() {

  int a, b, c, i, n = 0;

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

  for(i = a; i <= b; i++)
    if(c % i == 0)
      n++;

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

  return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <map>
#include <queue>
#include <vector>
#define mem(i,a) memset(i,a,sizeof(i))
#define PI acos(-1.0)
#define DMAX 10000+5
#define eps 1e-8
#define mp make_pair
#define INF 1000000000+9
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
inline void read(int &f){
	f=0;
    ll x=1;
    char ch=getchar();
    while(ch<48 || ch>57) {
        if(ch=='-') {
            x=-1;
        }
        ch=getchar();
    }
    while(ch<=57 && ch>=48) {
        f=f*10+ch-'0';
        ch=getchar();
    }
    f*=x;
} 
int n,ans;
int a[DMAX];
const int MOD=1000000000+7;
int cnt[1000000+5];
int INV(ll x){
	int tot=1;
	int y=MOD-2;
	for(;y;y>>=1,x=x*x%MOD){
		if(y&1){
			tot=tot*x%MOD;
		}
	}
	return tot;
}
int main(){
	read(n);
	for(int i=1;i<=n;i++){
		read(a[i]);
		int temp=a[i];
		for(int j=2;j*j<=temp;j++){
			if(temp%j==0){
				int tot=1;
				while((temp/=j)%j==0){
					tot++;
				}
				cnt[j]=max(cnt[j],tot);
			}
		}
		if(temp>1){
			cnt[temp]=max(1,cnt[temp]);
		}
	}
	int lcm=1;
	for(int i=1;i<=1000000;i++){
		while(cnt[i]--){
			lcm=(ll)lcm*i%MOD;
		}
	}
	for(int i=1;i<=n;i++){
		ans=(ans+(ll)lcm*INV(a[i]))%MOD;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, count = 0;
  cin >> N;
  vector<int> vec(N);
  
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  
  for (int i = 0; i < N; i++) {
    if (vec.at(i) == 0) continue;
    for (int j = i + 1; j < N; j++) {
      if (vec.at(i) == vec.at(j)) {
        vec.at(j) = 0;
        count++;
      }
    }
  }
  
  cout << N - count << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#include<algorithm>
using namespace std;
int main(){
    int n;
    cin>>n;
    while(n--){
        int t,m;
        (cin>>t).ignore()>>m;
        double t_ang=30*t,m_ang=6*m;
        t_ang+=30*(m/60.0);
        double dif=max(t_ang,m_ang)-min(t_ang,m_ang);
        dif=min(dif,360-dif);
        if(dif-30<0)cout<<"alert"<<endl;
        else if(dif-90>=0)cout<<"safe"<<endl;
        else cout<<"warning"<<endl;
    }
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
int dp[3010][3010];
string a,b;
string generateLCS(int n, int m) {
    string lcs = "";
    while (n > 0 && m > 0)
    {
        if (a[n-1]==b[m-1]) {
            lcs += a[n-1];
            n--;
            m--;
        }
        else {
            if (dp[n-1][m]>dp[n][m-1]) n--;
            else m--;
        }
    }
    reverse(lcs.begin(), lcs.end());
    return lcs;
}
string lcs(int n, int m) {
    pair<int,int> maxCell;
    int ans = 0;
    for (int i=0; i <= n; i++) {
        for (int j=0; j <= m; j++) {
            if (i==0 || j==0) dp[i][j] = 0;
            else if (a[i-1]==b[j-1]) dp[i][j] = dp[i-1][j-1] + 1;
            else dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            if (dp[i][j]>ans) {
                ans = dp[i][j];
                maxCell.first = i;
                maxCell.second = j;
            }
        }
    } 
    return generateLCS(maxCell.first, maxCell.second);
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> a >> b;
    cout << lcs(a.size(), b.size()) << "\n";
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);//直属の上司
  for(int i = 1; i < N; i++){
    cin >> A.at(i);
  }
  
  vector<int> B(N);//直属の部下の数
  for(int i = 1; i<N; i++){
    B.at(A.at(i) - 1)++;
  }
  
  for(int i = 0; i < N; i++){
    cout << B.at(i) << endl;
  }
}

Measured memory_bytes: 4792
N = int(input())
T,X,Y = 0,0,0

ans = "Yes"
for _ in range(N):
    t,x,y = map(int,input().split())
    t_need = abs(x - X) + abs(y - Y)
    if t - T < t_need:
        ans = "No"
        break
    if t - T > t_need:
        if ((t - T) - t_need) % 2 == 1:
            ans = "No"
            break
    T,X,Y = t,x,y

print(ans)

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

int main() {
	int a, b;
	while (cin >> a >> b, a, b) {
		int x = 0, y = 0, z = 0;

		int c = b - a;
		x = c / 1000;
		c -= x * 1000;

		y = c / 500;
		c -= y * 500;

		z = c / 100;
		cout << z << ' ' << y << ' ' << x << endl;
	}
	return 0;
}

Measured memory_bytes: 3052
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()
scores = {'r':p, 's':r, 'p':s}
ans = 0
for i in range(k):
    ans += scores[t[i]]
    flg = False
    for j in range(i+k, n, k):
        if (not flg) and t[j]==t[j-k]:
            flg = True
            continue
        flg = False
        ans += scores[t[j]]
print(ans)

Measured memory_bytes: 3316
# ABC045 B - 3人でカードゲームイージー / Card Game for Three (ABC Edit)
from collections import deque
SA = input()
SB = input()
SC = input()

A,B,C = [],[],[]

for sa in SA:
    A.append(sa)

for sb in SB:
    B.append(sb)

for sc in SC:
    C.append(sc)

A = deque(A)
B = deque(B)
C = deque(C)

is_first = True
ans = ''
t = ''
inf = True

while inf:
    if is_first:
        t = A.popleft()
        is_first = False
        continue
    if t == 'a':
        if len(A) == 0:
            ans = 'A'
            break
        else:
            t = A.popleft()
            continue
    elif t == 'b':
        if len(B) == 0:
            ans = 'B'
            break
        else:
            t = B.popleft()
            continue
    elif t == 'c':
        if len(C) == 0:
            ans = 'C'
            break
        else:
            t = C.popleft()
            continue
print(ans)

Measured memory_bytes: 3316
#include <iostream>

int main() {
	int n;
	char s[300005];
	int w[300005] = {};
	int e[300005] = {};
	
	scanf("%d %s", &n, s + 1);
	
	w[1] = (s[1] == 'W' ? 1 : 0);
	for (int i = 2; i <= n; ++i) w[i] = w[i - 1] + (s[i] == 'W' ? 1 : 0);
	
	e[n] = (s[n] == 'E' ? 1 : 0);
	for (int i = n - 1; i >= 1; --i) e[i] = e[i + 1] + (s[i] == 'E' ? 1 : 0);
	
	int min = 1000000;
	for (int i = 1; i <= n; ++i) {
		int t = w[i - 1] + e[i + 1];
		if (t < min) min = t;
	}
	printf("%d\n", min);
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;

int main()
{
    uint a, b, c;
    cin >> a >> b >> c;

    uint res = 0;

    for (uint i = a; i <= b; i++) {
        res += !(c % i);
    }

    cout << res << endl;
}



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

int mod = 1000000007;

int main()
{
    string A, B, C;
    cin >> A >> B >> C;

    int a = 0;
    int b = 0;
    int c = 0;
    char turn = 'a';
    bool x = true;
    while(x)
    { 
        if (turn == 'a')    
        {
            if (a == A.size())
            {
                cout << "A";
                break;
            }
            turn = A[a];
            a++;
            continue;
        }
        if (turn == 'b')
        {
            if (b == B.size())
            {
                cout << "B";
                break;
            }
            turn = B[b];
            b++;
            continue;
        }
        if (turn == 'c')
        {
            if (c == C.size())
            {
                cout << "C";
                break;
            }
            turn = C[c];
            c++;
            continue;
        }
    }
}

Measured memory_bytes: 256
//kalyanchirla
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
//setbase - cout << setbase (16)a; cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val
using namespace std;
#define int long long
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define csl ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define vi vector<int>
#define mii map<int,int>
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define mod 1000000007

int32_t main()
{ 
    csl;

    string s;
    cin >> s;

    int freq[26];
    for(int i=0;i<26;i++)
    {
        freq[i]=0;
    }
    for(int i=0;i<s.length();i++)
    {
        int a = s[i]-97;
        if(freq[a]==0)
        {
            freq[a]++;
        }
        else
        {
            cout << "no" << "\n";
            return 0;
        }
    }
    cout<< "yes" << "\n";
}

Measured memory_bytes: 3648
def main():

    A, B = map(int, input().split())

    coin = 0

    if A > B:
        coin += A
        A -= 1
    else:
        coin += B
        B -= 1

    if A > B:
        coin += A
        A -= 1
    else:
        coin += B

    print(coin)


main()


Measured memory_bytes: 2940
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#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)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
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; }
typedef long long ll;
typedef pair<int,int> P;

ll f(vector<P> vp){
  int n = vp.size();
  ll res = 0;
  rep(i,n)chmin(vp[i].first,n);
  vector<int> s[n+1];
  rep(i,n)s[vp[i].first].push_back(vp[i].second);
  priority_queue<int> pq;
  for(int i = n;i>0;i--){
    for(int x:s[i])pq.push(x);
    if(!pq.empty()){
      res += pq.top();
      pq.pop();
    }
  }
  return res;
}

void solve() {
  int n;
  cin >> n;
  int k[n],lt[n],rt[n];
  rep(i,n)cin >> k[i] >> lt[i] >> rt[i];
  vector<P> l;
  vector<P> r;
  ll ans = 0;
  rep(i,n){
    ans += min(lt[i],rt[i]);
    if(lt[i]>rt[i])l.emplace_back(k[i],lt[i]-rt[i]);
    else r.emplace_back(n-k[i],rt[i]-lt[i]);
  }
  ans += f(l);
  ans += f(r);
  cout << ans << endl;
}

int main(){
  int t;
  cin >> t;
  rep(i,t)solve();
  return 0;
}

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

int d[100], a[100];
map<vector<int>, int>id;
map<int, vector<int>>re;
int dp[100][5040];

int main() {
	int n; scanf("%d", &n);
	rep(i, n)scanf("%d", &d[i]);
	rep(i, n)scanf("%d", &a[i]);
	vector<int>v(7); iota(v.begin(), v.end(), 0);
	int p = 0;
	do {
		id[v] = p; re[p] = v;
		int cnt = 0, t = 0;
		for (int i : v) {
			rep(j, 7) {
				if ((t >> j & 1) && abs(j - i) <= d[j])cnt += a[j];
			}
			t |= 1 << i;
		}
		dp[0][p] = cnt;
		p++;
	} while (next_permutation(v.begin(), v.end()));
	int ans = 0;
	for (int i = 1; i + 6 < n; i++)rep(j, 5040) {
		vector<int>v = re[j];
		rep(k, 8) {
			vector<int>t = v;
			t.insert(t.begin() + k, 7);
			int cnt = 0, p = 0;
			for (int u : t){
				if (u == 7) {
					rep(y, 8) {
						if ((p >> y & 1) && y + d[i - 1 + y] >= 7)
							cnt += a[i - 1 + y];
					}
				}
				if ((p >> 7 & 1) && 7 - d[i + 6] <= u)cnt += a[i + 6];
				p |= 1 << u;
				vector<int>q = t; q.erase(find(q.begin(), q.end(), 0));
				for (int&c : q)c--;
				int v = id[q];
				dp[i][v] = max(dp[i][v], dp[i - 1][j] + cnt);
				ans = max(ans, dp[i][v]);
			}
		}
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 6344
//Radhe Radhe
#include<bits/stdc++.h>
#define godspeed  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define mod 1000000007 //1e9+7
#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define rep1(i,a,b)    for(ll i=a; i<=b; i++)
#define repVect(i,n)    for(ll i=0; i<sum.size(); i++)
#define fixed cout.setf(ios::fixed);
#define Precise cout.precision(7);
#define yes cout<<"Yes"<<'\n';
#define no cout<<"No"<<'\n';
using namespace std;

int main()
{
    godspeed
    ll  i,j,n,k,ans,cnt=0;
    string s;
    cin>>n;
    cout<<180*(n-2)<<endl;
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	ull N, A, B;
	cin >> N >> A >> B;

	ull big, small;
	if (A >= B) {
		big = A;
		small = B;
	} else {
		big = B;
		small = A;
	}

	if ( (big - small) % 2 == 0 ) {	//偶数のとき
		cout << (big - small) / 2 << endl;
		// printf("%llu\n", (big - small) / 2);
	} else {	//奇数のとき
		ull smallTo1 = small - 1;
		ull bigToN = N - big;

		if (smallTo1 < bigToN) {
			ull step1 = smallTo1 + 1;
			ull step2 = (big - step1) / 2;
			cout << step1 + step2 << endl;
		} else {
			ull step1 = bigToN + 1;
			ull step2 = (N - (small + step1)) / 2;
			cout << step1 + step2 << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int N;
    cin >> N;
    int h[N];
    rep(i, N) cin >> h[i];
    int ans = h[0];
    rep(i, N-1){
        if(h[i] > h[i+1]) continue;
        else ans += h[i+1]-h[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<LL,LL>
#define x first
#define y second
#define pi acos(-1)
#define sqr(x) ((x)*(x))
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
#define less Less
#define EPS 1e-4
#define arg ARG
#define cpdd const pdd
#define rank Rank
#define KK 500
#define MXN 200005
vector<int> v[100005];
int vis[100005][15];
int color[100005];
int main(){
    int n,m;
    scanf("%d %d",&n,&m);
    for(int i = 0;i<m;i++){
        int x,y;
        scanf("%d %d",&x,&y);
        v[x].pb(y);
        v[y].pb(x);
    }
    int q;
    scanf("%d",&q);
    vector<tuple<int,int,int> > qu;
    for(int i = 0;i<q;i++){
        int a,b,c;
        scanf("%d %d %d",&a,&b,&c);
        qu.push_back(make_tuple(a,b,c));
    }
    reverse(qu.begin(),qu.end());
    for(auto it:qu){
        int vv,d,c;
        tie(vv,d,c)=it;
        queue<pii> q;
        q.push(mp(vv,d));
        vis[vv][d]=1;
        if(color[vv]==0)color[vv]=c;
        while(!q.empty()){
            pii p=q.front();
            q.pop();
            if(p.y==0)continue;
            for(auto it:v[p.x]){
                if(!vis[it][p.y-1]){
                    vis[it][p.y-1]=1;
                    q.push(mp(it,p.y-1));
                    if(color[it]==0)
                        color[it]=c;
                }
            }
        }
    }
    for(int i = 1;i<=n;i++)
        printf("%d\n",color[i]);
}

Measured memory_bytes: 14704
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

int N=1<<18;
class StarrySkyTree{
public:
  ll Mi[555555],A[555555];
  void init(){memset(Mi,0,sizeof(Mi)),memset(A,0,sizeof(A));}
  void add(int a,int b,ll x,int k=0,int l=0,int r=N) {
    if(r<=a||b<=l) return;
    if(a<=l&&r<=b){
      A[k]+=x;
      while(k){
        k=(k-1)/2;
        Mi[k]=min(Mi[k*2+1]+A[k*2+1],Mi[k*2+2]+A[k*2+2]);
      }
      return;
    }
    add(a,b,x,k*2+1,l,(l+r)/2);
    add(a,b,x,k*2+2,(l+r)/2,r);
  }
  ll getMin(int a,int b,int k=0,int l=0,int r=N) {
    if(r<=a||b<=l)return LLONG_MAX;if(a<=l&&r<=b)return Mi[k]+A[k];
    ll left=getMin(a,b,k*2+1,l,(l+r)/2),right=getMin(a,b,k*2+2,(l+r)/2,r);
    return min(left,right)+A[k];
  }
};

StarrySkyTree t;

void Main() {
  ll n,m;
  cin >> n >> m;
  t.init();
  t.add(2,n+1,MAXL);
  vector<P> v[n+1];
  rep(i,m) {
    ll l,r,c;
    cin >> l >> r >> c;
    v[r].pb(P(l,c));
  }
  REP(i,2,n+1) {
    t.add(i,i+1,-MAXL);
    ll ans=MAXL;
    rep(j,v[i].size()) {
      P p=v[i][j];
      t.add(p.F,i,p.S);
      ans=min(ans,t.getMin(p.F,i));
      t.add(p.F,i,-p.S);
    }
    t.add(i,i+1,ans);
  }
  ll ans=t.getMin(n,n+1);
  if(ans==MAXL) ans=-1;
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


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

int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    for ( int i = 0; i < n; i++ ) {
        cin >> p[i];
    }

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

    int sum = 0;
    for ( int i = 0; i < n; i++ ) {
        if ( i == n - 1 ) {
            sum += p[i] / 2;
        }
        else {
            sum += p[i];
        }
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), check, cnt = 1;
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}

		Arrays.sort(a);

		check = a[0];
		for (int i = 1; i < a.length; i++) {
			if (a[i] != check) {
				cnt++;
			}
			check = a[i];
		}

		System.out.println(cnt);
	}

}

Measured memory_bytes: 21716
#include<iostream>
#include <list>
#include<stack>
#include<queue>
#include <vector>
#include <set>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include <functional>
#include<fstream>

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define LL long long
#define CLR(a) memset((a),0,sizeof(a))
#define SZ(x) (int((x).size()))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl
using namespace std;

const LL MOD = 1000000007;// 10^9+7
const int INF = (1 << 30);


//変数


double S(LL x) {
	double res = 0;
	while (x) {
		res += x % 10;
		x /= 10;
	}
	return res;
}
double f(LL x) {
	double res = x;
	res /= S(x);
	return res;
}




//サブ関数
//入力
void input()
{

}


//計算
void calc()
{


}


//出力
void output()
{

}


//デバッグ
void debug()
{
	int K;
	cin >> K;
	set<LL> data;
	vector<LL> res;

	int siz = 0;
	REP(siz,12){
		string post = "";
		REP(i, siz)post += to_string(9);
		FOR(i, 1, 10000) {
			string res = post;
			res += to_string(i);
			reverse(res.begin(), res.end());
			data.insert(stoll(res));
		}
	}
	for (auto num : data) {
		res.push_back(num);
	}
	sort(res.begin(), res.end());

	//REP(i, K)cout << res[i] << endl;

start:;
	vector<bool> banish(res.size(), false);
	REP(i, res.size())FOR(j, i+1, res.size()) {
		if (f(res[i]) > f(res[j])) {
			banish[i] = true;
			break;
		}
	}
	for (int i = banish.size() - 1; i >= 0; i--) {
		if (banish[i]) {
			res.erase(res.begin() + i);
		}
	}

	//cout << siz << endl;
	//for (auto num : data)cout << num << endl;
	REP(i, K)cout << res[i] << endl;
	int N;
	cin>>N;
}


//メイン関数
int main()
{
	input();
	calc();
	output();
	debug();
	
	return 0;
}


Measured memory_bytes: 6008
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<cstdlib>
#include<iomanip>
#include<queue>
#include<set>

using namespace std;

char a[110][110];

int ans = 0;
int h, w;

void Solution(int y, int x, char z)
{
    a[y][x] = '0';
    
    if(a[y+1][x] == z)
    {
        Solution(y+1, x, z);
    }
    
    if(a[y - 1][x] == z)
    {
        Solution(y-1, x, z);
    }
    
    if(a[y][x + 1] == z)
    {
        Solution(y, x + 1, z);
    }
    
    if(a[y][x - 1] == z)
    {
        Solution(y, x - 1, z);
    }
}

int main()
{
    while (cin>>h>>w, h)
    {
        ans = 0;
        
        for(int i = 0; i < h; i++)
        {
            for(int j = 0; j < w; j++)
            {
                a[i][j] = '0';
            }
        }
        
        if(h == 0)
        {
            break;
        }
        
        for(int i = 0; i < h; i++)
        {
            for(int j = 0; j < w; j++)
            {
                cin >> a[i][j];
            }
        }
        
        
        for(int i = 0; i < h; i++)
        {
            for(int j = 0; j < w; j++)
            {
                if(a[i][j] != '0')
                {
                    Solution(i, j, a[i][j]);
                    ans++;
                }
            }
        }
        
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 1632
#include <iostream>
#include <string>
#include <algorithm>
#include <cassert>
#include <limits>
#include <numeric>
#include <type_traits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <complex>
#include <climits>
#include <queue>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll, ll> P;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

const double PI = 3.1415926535897932;
/******define variable start******/
string S;
/*******define variable end*******/
ll solve(){
    cin >> S;
    REP(i, S.size()-1){
        if(S.substr(i, 1) == S.substr(i+1, 1)){
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
    return 0;
}
int main(){

    //clock_t start = clock();
    cout << std::fixed << std::setprecision(10);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll end_solve = solve();
    /*
    clock_t end = clock();
    const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
    printf("time %lf[ms]\n", time);
    */
    return (int)end_solve;
}


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

int main()
{	
	int H,W;
	
	while(1){
		cin >> H >> W;
		if(H==0 && W == 0) break;
		for(int i = 0; i<H;i++){
			for(int j = 0; j<W;j++){
				if(i != 0 && i !=H-1 && j != 0 && j!=W-1) cout << ".";
				else cout << "#";
				}
				cout<<"\n";
				}
			cout<<endl;
			}
			return 0;
	}

Measured memory_bytes: 1152
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# define MOD 1000000000+7
# define INF 1000000000
using namespace std;

int main() {
	vector<int> S;
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '0') {
			S.emplace_back(0);
		}
		if (s[i] == '1') {
			S.emplace_back(1);
		}
		if(s[i]=='B'&&S.size()) {
			S.pop_back();
		}
	}
	for (int i = 0; i < S.size(); i++) {
		cout << S[i];
	}
	cout << endl;
}



Measured memory_bytes: 256
S = input()
e = []
o = []
for i in range(len(S)):
  if i%2==0:
    e.append(S[i])
  else:
    o.append(S[i])
e = list(set(e))
o = list(set(o))
if 'R' in o or 'L' in e:
  print('No')
else:
  print('Yes')

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

int main()
{
    int n,i;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    for(i = 0;i < n;++i){
        cin >> a.at(i);
    }
    vector<int> temp(n,0);
    temp.at(0) += a.at(0);
    for(i = 0;i < n;++i){
        cin >> b.at(i);
        temp.at(0) += b.at(i);
    }
    for(i = 1;i < n;++i){
        temp.at(i) = temp.at(i-1)-b.at(i-1)+a.at(i);
    }
    int ans = temp.at(0);
    for(i = 1;i < n;++i){
        if(temp.at(i) > ans){
            ans = temp.at(i);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
	string s;
	int n;
	cin >> n;
	cin >> s;
	int count = 1;
	for (int i = 0; i < s.size()-1; i++) {
		if (s[i] != s[i + 1]) {
			count++;
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 512
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def POW(x, y): return pow(x, y, MOD)
def INV(x, m=MOD): return pow(x, m - 2, m)
def DIV(x, y, m=MOD): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

# factorials
_nfact = 2 * (10 ** 5) + 10
facts = [0] * _nfact
t = facts[0] = 1
for i in range(1, _nfact):
    t = (t * i) % MOD
    facts[i] = t
ifacts = [0] * _nfact
t = ifacts[-1] = INV(facts[-1])
for i in range(_nfact - 1, 0, -1):
    t = (t * i) % MOD
    ifacts[i - 1] = t

def binomial(m, n):
    return facts[m] * ifacts[n] * ifacts[m - n]

def main():
    N, A, B, C = LI()
    D = DIV(100, 100 - C)
    ans = 0
    ap, bp, abp = [1], [1], [POW(A + B, N)]
    for _ in range(0, N + 1):
        ap.append(ap[-1] * A % MOD)
        bp.append(bp[-1] * B % MOD)
        abp.append(abp[-1] * (A + B) % MOD)
    for m in range(N, 2 * N):
        x = binomial(m - 1, N - 1) * DIV(
            ap[N] * bp[m - N] + ap[m - N] * bp[N],
            abp[m - N]) % MOD
        y = (m * D) % MOD
        ans = (ans + (x * y) % MOD) % MOD
    return ans

print(main())

Measured memory_bytes: 31044
#include <stdio.h>

int main(void)
{
    int n, ans = 0;
    int num[205];
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        scanf("%d", &num[i]);
    int f = 1;
    while (f)
    {
        for (int i = 0; i < n; i++)
        {
            if (num[i] % 2 == 0)
                num[i] /= 2;
            else
            {
                f = 0;
                break;
            }
            if (i == n - 1)
                ans++;
        }
    }
    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    int n; cin >> n;
    int MIN=101, MAX=0;
    vector<int> a(100);
    for(int i=0; i<n ;i++){
        cin >> a[i];
        if(MIN>a[i]) MIN = a[i];
        if(MAX<a[i]) MAX = a[i];
    }

    ll ans = 1000000000000;
    for(int i=MIN; i<=MAX; i++){
        ll tmp=0;
        for(int j=0; j<n; j++){
            tmp += (a[j] - i) * (a[j] - i);
        }
        ans = min(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#ifndef LOCAL
#pragma GCC optimize(3)
#else
#endif
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

typedef long long ll;
const double eps=1e-6;
const int inf=0x3f3f3f3f;
const int maxn=1e5+100;

int main() {
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif // LOCAL
    int a, b;
    cin >> a >> b;
    cout << max(max(a+b, a-b), a*b);
    return 0;
}

Measured memory_bytes: 256
i = list(map(int, input().split()))

n = i[0]
l = i[1]

aji = [] 

for i in range(n):
  aji.append(l+i)

ajimap = list(map(abs, aji))

idx = ajimap.index(min(ajimap))

sum = 0

for i in range(n):
  if i != idx:
    sum += aji[i]
    
print(sum)

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

int main(void){
  int cntI, cntJ;
  string s;
  while(cin>>s){
    cntI = cntJ = 0;
    for (int i=0; i<=s.size()-3; i++){
      //cout << s.substr(i,3) << endl;
      if (s.substr(i, 3)=="JOI") cntJ++;
      if (s.substr(i, 3)=="IOI") cntI++;
    }
    cout << cntJ << endl << cntI << endl;
  }
  return 0;
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
#define pb push_back

using ll = long long;
using namespace std;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
const int INFint = 1e9;
const ll INFll = 1e18;
ll MOD=1e9+7;

ll gcd(ll a, ll b) { return __gcd(a,b); } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; } //最大公倍数

// aのn乗をMODで割りながら計算する
ll modpow(ll a, ll n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1; // right shift
  }
  return res;
}

// MODを法としたaの逆元を計算する
ll modinv(ll a) {
  return modpow(a, MOD - 2);
}

int main(){
  int H,W;
  int nx[4] = {0,0,1,-1},ny[4]={1,-1,0,0};
  string s[100];
  int a[100][100]={0};
  cin>>H>>W;
  for (int i(0);i<H;i++) cin>>s[i];
  int cnt(0);
  for (int i(0);i<H;i++){
    for (int j(0);j<W;j++){
      if (s[i][j] == '.') cnt++; 
    }
  }
  queue<pair<int,int>> q;
  q.push({0,0});
  s[0][0] = '#';
  pair<int,int> now;
  while(!q.empty()){
    now = q.front();q.pop();
  //  cout << now.first << " " << now.second << endl;
    for (int i(0);i<4;i++){
      int next_x = now.first+nx[i], next_y = now.second+ny[i];
      if (next_x >= 0 && next_x < W && next_y < H && next_y >= 0 && s[next_y][next_x] == '.'){
        a[next_y][next_x] = a[now.second][now.first] + 1;
        q.push({next_x,next_y});
        s[next_y][next_x] = '#';
      }
    }
  }
  if (a[H-1][W-1] == 0) cout << -1 << endl;
  else cout << cnt - a[H-1][W-1] -1 << endl;
  return 0;
}



Measured memory_bytes: 896
#include <iostream>
using namespace std;
int main(void){
    int h, w;
    
    for (int a = 0;;a++){
         cin >> h >> w;
        if(h == 0 && w == 0){
            break;
        }
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (i == 0 || i == h-1 || j == 0 || j == w-1) {
                cout << "#";
            } else {
                cout << ".";
            }
        }
        cout << endl;
    }
    cout << endl;
}
}


Measured memory_bytes: 3032
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
 int n;
 string s;
 cin>>n>>s;
 int ans=0;
 for(int i=0;i<n-2;i++){
 	if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C') {ans++;}
}
cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20);
    int n; cin >> n;
    vector<int> a(n);
    for (int &x : a) {
        cin >> x;
    }
    auto check = [&]() {
        if (is_sorted(a.begin(), a.end())) {
            cout << "YES\n";
            exit(0);
        }
    };
    check();
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            swap(a[i], a[j]);
            check();
            swap(a[i], a[j]);
        }
    }
    cout << "NO\n";
}


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

int main() {
  string S,T,U;
  int a,b;
  cin >> S >> T >> a >> b >>U;
  if (U == S){
    a -= 1;
  }
  else {
    b -= 1;
  }
  cout << a << " "<< b << endl;
}


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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    int n;
    cin >> n;
    vector<pair<int, int>> ab(n);
    for (int i=0; i<n; ++i) {
        cin >> ab.at(i).first >> ab.at(i).second;
    }

    priority_queue<pair<int, bool>, vector<pair<int, bool>>, greater<pair<int, bool>>> que;
    for (auto p : ab) {
        que.push({p.first, false});
        que.push({p.second+1, true});
    }
    int f = 0, b = n;
    int res = 0;
    if (n%2 == 1) {
        while (!que.empty()) {
            auto p = que.top(); que.pop();
            if (p.second) ++f;
            else --b;
            if (f <= n/2 && b <= n/2) res += que.top().first - p.first;
        }
    } else {
        int s1 = INF, t1 = -1, s2 = INF, t2 = -1;
        while (!que.empty()) {
            auto p = que.top(); que.pop();
            if (p.second) ++f;
            else --b;
            if (f <= n/2-1 && b <= n/2) {
                chmin(s1, p.first);
                chmax(t1, que.top().first);
            }
            if (f <= n/2 && b <= n/2-1) {
                chmin(s2, p.first);
                chmax(t2, que.top().first);
            }
        }
        res = (t1 + t2) - (s1 + s2) - 1;
    }
    cout << res << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


Measured memory_bytes: 8920
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define fo(i,j,n) for (int i=(j); i < (n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() { 
    double w , h , x, y; cin >> w >> h >> x >> y;
    double res = h * w / 2;
    int is = x == w / 2 && y == h / 2 ? 1 : 0;

    cout << fixed << setprecision(12);
    cout << res << " " << is << ln;
} 


Measured memory_bytes: 256