akhauriyash/Code-Regression huggingface dataset:
#include <math.h>

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define PI 3.14159265358979323846264338327950L
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))

int main() {
  string S;

  cin >> S;

  int sum = 700;

  rep(i, S.size()) {
    if (S[i] == 'o') sum += 100;
  }

  cout << sum << endl;
}


Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

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

        String[] s = readArray(sc);
        String[] t = readArray(sc);

        System.out.println(solve(s, t));

        sc.close();
    }

    static String[] readArray(Scanner sc) {
        int size = sc.nextInt();
        String[] result = new String[size];
        for (int i = 0; i < result.length; ++i) {
            result[i] = sc.next();
        }

        return result;
    }

    static int solve(String[] s, String[] t) {
        Map<String, Integer> sValueToCount = buildValueToCount(s);
        Map<String, Integer> tValueToCount = buildValueToCount(t);

        return Math.max(0,
                sValueToCount.keySet().stream()
                        .mapToInt(sValue -> sValueToCount.get(sValue) - tValueToCount.getOrDefault(sValue, 0)).max()
                        .getAsInt());
    }

    static Map<String, Integer> buildValueToCount(String[] values) {
        Map<String, Integer> valueToCount = new HashMap<>();
        for (String value : values) {
            valueToCount.put(value, valueToCount.getOrDefault(value, 0) + 1);
        }

        return valueToCount;
    }
}

Measured memory_bytes: 28628
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"
vector<string> split(const string &str, char delim) {
	vector<string> res;
	size_t current = 0, found;
	while ((found = str.find_first_of(delim, current)) != string::npos) {
		res.push_back(string(str, current, found - current));
		current = found + 1;
	}
	res.push_back(string(str, current, str.size() - current));
	return res;
}

int main() {
	while(1){
		string st; cin >> st;
		if (st == "#")break;
		vector<string>exprs(split(st,'|'));
		bool ans = false;
		for (auto expr:exprs) {
			expr = expr.substr(1, expr.size() - 2);
			vector<string>lites(split(expr, '&'));
			set<char>trues, falses;
			for (auto lite : lites) {
				if (lite[0] == '~')falses.emplace(lite[1]);
				else trues.emplace(lite[0]);
			}
			bool ok = true;
			for (auto t : trues) {
				for (auto f : falses) {
					if (t == f)ok = false;
				}
			}
			if (ok)ans = true;
		}
		if (ans)cout << "yes" << endl;
		else cout << "no" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3112
from collections import defaultdict

def main():
    N, M = map(int, input().split())
    a_b_dict = defaultdict(int)
    for _ in range(N):
        a, b = map(int, input().split())
        a_b_dict[a] += b
    ans = 0
    for a, b in sorted(a_b_dict.items()):
        if M >= b:
            M -= b
            ans += a * b
        else:
            ans += a * M
            break
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 92292
#include <iostream>

int main(int argc, char** argv)
{
  long long L, R;
  std::cin >> L >> R;
 
  long long m = 2018;
  for (long long i = L; i < R; i++) {
    long long ii = i % 2019;
    if (ii == 0) {
        m = 0;
        break;
    }
    for (long long j = i + 1; j <= R; j++) {
      long long jj = j % 2019;
      if (jj == 0) {
          m = 0;
          break;
      }
      long long ij = ii * jj;
      long long n = ij % 2019;
      if (m > n) {
        m = n;
      }
    }
    if (m == 0) {
      break;
    } 
  }

  std::cout << m << std::endl;

  return 0;
}

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

int main(int argc, char* argv[]){
    int a, b, c;
    int divisors = 0;
    scanf("%d %d %d", &a, &b, &c);
    for(int i = a; i <= b; i++){
        if (c % i == 0) divisors++;
    }
    printf("%d\n", divisors);
}


Measured memory_bytes: 2748
<?php
//$N = (int)trim(fgets(STDIN));
//$S = trim(fgets(STDIN));
list($N,$K) = array_map('intval',explode(" ",trim(fgets(STDIN))));
$A = array_map('intval',explode(" ",trim(fgets(STDIN))));

for($i=0;$i<$K;$i++) {
  $A=kaisetu($A);
  //これ以上増えない
  if (array_sum($A)==$N*$N) break;
}
printf("%s\n",implode(" ",$A));
//座標を照らしている電球の数が欲しい
//最大はN
function getLightNum($A) {
  global $N;
  $AA = array_fill(0,$N,0);
  for($i=0;$i<$N;$i++) {
    if ($A[$i]==0) {
      $AA[$i]+=1;
      continue;
    }
    //自分の明るさが1なら前後1(3箇所)+1出来る
    for($j=$i-$A[$i];$j<=$i+$A[$i];$j++) {
      if (isset($AA[$j])) {
        $AA[$j]++;
      }
    }
  }
  return $AA;
}

function kaisetu($A)
{
  global $N;
  $B = array_fill(0,$N,0);
  for($i=0;$i<$N;$i++) {
    $l = max(0,$i-$A[$i]);
    $r = min($N-1,$i+$A[$i]);
    $B[$l]++;
    if ($r+1<$N) $B[$r+1]--;
  }
  for($i=1;$i<$N;$i++) $B[$i]+=$B[$i-1];
  return $B;
}


Measured memory_bytes: 35884
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

int main()
{
    ll a, b;
    cin >> a >> b;
    if ((a + b) % 2 == 0)
    {
        cout << ((a + b) / 2) << endl;
    }
    else
    {
        cout << "IMPOSSIBLE" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define rev1(i,n) for(int i=n;i>0;i--)
#define pb push_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vpii vector<pair<int,int> >
#define vb vector<bool>
#define pii pair<int,int>
#define F first
#define S second
#define INF 1e9+7
typedef long long int ll;

void solve(){
  int a;cin>>a;
  string s;cin>>s;
  if(a<3200) cout<<"red";
  else cout<<s;
}
signed main() {
    // your code goes here
    IOS
    ll t=1;
    //cin>>t;
    rep1(i,t){
        solve(); 
    }
}

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

int main() {
    int N;
    cin >> N;

    int V[N];
    int C[N];
    for (int i = 0; i < N; i++) {
        cin >> V[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> C[i];
    }

    int result = 0;
    for (int i = 0; i < N; i++) {
        int aho = V[i] - C[i];
        if (aho> 0) {
            result += aho;  
        }
    }

    cout << result << endl;

	return 0;
}


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

int main() {
  int64_t N,A,B,a=0,b=0,c=0;
  cin >> N >> A >> B;
  
  a=N/(A+B);
  b=N%(A+B);
    if (b>=A){
    c=A;
    }
    else {
    c=b;
    }
  
  cout << a*A+c << endl;
}

Measured memory_bytes: 256
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){
    int n,ans=0; cin>>n; 
    if (n==1) cout << 0 ,exit(0);
    while (n--){
        int a; cin>>a;
        while (a%2==0) {
            ans++; a /= 2;
        }
    }
    cout << ans << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


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

namespace ConsoleApplication1
{
    class Solution
    {
        public long Proc(string Source)
        {
            long n = Source.Length;
            long src = long.Parse(Source);
            long number = 0;

            if (n % 2 == 0)
            {
                for (long i = 1; i < n; i += 2)
                {
                    number += (long)Math.Pow(10, i) - (long)Math.Pow(10, i - 1);
                }
            }
            else
            {
                for (long i = 1; i < n; i += 2)
                {
                    number += (long)Math.Pow(10, i) - (long)Math.Pow(10, i - 1);
                }

                number += (src % (long)Math.Pow(10, n - 1)) +
                    ((src / (long)Math.Pow(10, n - 1) - 1) * (long)Math.Pow(10, n - 1));
            }

            return number;
        }

        public long Proc2(string Source)
        {
            long src = long.Parse(Source);
            long count=0;

            for (long i = 1; i <= src; i++)
            {
                if (i.ToString().Length % 2 == 1) count++;
            }

            return count;
        }
    }

    public class Program
    {
        static void Main(string[] args)
        {
            try
            {
                var str = Console.ReadLine();
                var s = new Solution();
                var re = s.Proc2(str);
                Console.WriteLine(re);

                //Random rnd = new System.Random();
                //while (true)
                //{
                //    string src = rnd.Next(1, 10000).ToString();
                //    var s = new Solution();
                //    s.Proc2("405");
                //    s.Proc("405");
                //    if (s.Proc(src) != s.Proc2(src))
                //    {
                //        throw new Exception("");
                //    }
                //    Console.WriteLine("Cp");
                //}

                //var str = Console.ReadLine();
                

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            //Console.WriteLine("終了");
            //Console.Read();
        }


    }
}

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

int main(){
  vector<vector<int>> b(3,vector<int> (3));
  int n;
  rep(i,3){
    for (int j=0;j < 3;j++) cin >> b[i][j];
  }
  cin >> n;
  bool f=false;
  vector<int> num(n);
  rep(i,n) cin >> num[i];
  for (int h=0;h < n;h++){
    for (int i=0;i < 3;i++){
       for (int j=0;j <3;j++){
         if (num[h]==b[i][j]) b[i][j]=0;
       } 
    }
    if (b[0][0]==0 && b[0][1]==0 && b[0][2]==0) f=true;
    else if (b[1][0]==0 && b[1][1]==0 && b[1][2]==0) f=true;
    else if (b[2][0]==0 && b[2][1]==0 && b[2][2]==0) f=true;
    else if (b[0][0]==0 && b[1][0]==0 && b[2][0]==0) f=true;
    else if (b[0][1]==0 && b[1][1]==0 && b[2][1]==0) f=true;
    else if (b[0][2]==0 && b[1][2]==0 && b[2][2]==0) f=true;
    else if (b[0][0]==0 && b[1][1]==0 && b[2][2]==0) f=true;
    else if (b[0][2]==0 && b[1][1]==0 && b[2][0]==0) f=true;
  }
  if (f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

public class Main {
	static class Node {
		int key = 0;
		Node parent = NIL;
		Node left = NIL;
		Node right = NIL;
	}
	static Node NIL = new Node();
	
	static class Tree {
		Node root = NIL;
	}
	
	public static void main(String[]  args) {
		int m = nextInt();
		
		Tree tree = new Tree();
		
		for (int i = 0; i < m; i ++) {
			next();
			switch (nextbuf[0]) {
				case 'i':
					insert(tree, nextInt());
					break;
				case 'f':
					System.out.println(find(tree, nextInt()) ? "yes": "no");
					break;
				default:
					inorder(tree.root);
					System.out.println();
					preorder(tree.root);
					System.out.println();
					break;
			}
		}
	}
	
	static void insert(Tree tree, int key) {
		Node z = new Node();
		z.key = key;
		Node y = NIL;
		Node x = tree.root;
		
		while (x != NIL) {
			y = x;
			x = (key < x.key) ? x.left: x.right;
		}
		z.parent = y;
		
		if (z.parent == NIL) {
			tree.root = z;
		} else if (z.key < z.parent.key) {
			z.parent.left = z;
		} else {
			z.parent.right = z;
		}
	}
	
	static boolean find(Tree tree, int key) {
		Node x = tree.root;

		while (x != NIL) {
			if (key == x.key) return true;
			x = (key < x.key) ? x.left: x.right;
		}
		return false;
	}

	static void preorder(Node u) {
		if (u == NIL) return;

		System.out.print(" ");
		System.out.print(u.key);
		preorder(u.left);
		preorder(u.right);
	}

	static void inorder(Node u) {
		if (u == NIL) return;

		inorder(u.left);
		System.out.print(" ");
		System.out.print(u.key);
		inorder(u.right);
	}
	
	private static byte[] buf = new byte[1 << 20];
	private static int len = 0;
	private static int ptr = 0;

	private static byte read() {
		if (ptr >= len) {
			try {
				len = System.in.read(buf);
			} catch (Exception e) {
			}
			ptr = 0;
		}

		return buf[ptr++];
	}

	private static int nextInt() {
		int num = 0;

		byte b = read();
		while(!Character.isDigit(b) && b != '-') b = read();
		int sign;
		if (b == '-') {
			sign = -1;
			b = read();
			if (!Character.isDigit(b)) return 0;
		} else {
			sign = 1;
		}
		
		while(Character.isDigit(b)) {
			num *= 10;
			num += sign * (b - '0');
			b = read();
		}
		
		return num;
	}

	private static byte[] nextbuf = new byte[11];
	private static int nextlen;

	private static void next() {
		nextlen = 0;

		byte b = read();
		while(!Character.isAlphabetic(b) && !Character.isDigit(b)) b = read();
		while(Character.isAlphabetic(b) || Character.isDigit(b)) {
			nextbuf[nextlen++] = b;
			b = read();
		}
	}
} 



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

struct node { int x,y; }a[300010];

stack<node> st1,st2;

int mx[1200010],tag[1200010],w,h,n,ans;

inline int rd()
{
	int x=0;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar());
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

inline bool cmp(node x,node y) { return x.x<y.x; }

inline void turn() { swap(w,h);for (int i=1;i<=n;i++) swap(a[i].x,a[i].y); }

inline void modify(int o,int l,int r,int x,int y,int hh)
{
	if (l>=x&&r<=y) { mx[o]+=hh;tag[o]+=hh;return; }
	int mid=(l+r)>>1;
	if (x<=mid) modify(o<<1,l,mid,x,y,hh);
	if (y>mid) modify(o<<1|1,mid+1,r,x,y,hh);
	mx[o]=max(mx[o<<1],mx[o<<1|1])+tag[o];
}

inline void gao()
{
	while (!st1.empty()) st1.pop();
	while (!st2.empty()) st2.pop();
	memset(mx,0,sizeof(mx));
	memset(tag,0,sizeof(tag));
	sort(a+1,a+n+1,cmp);
	for (int i=1;i<n;i++)
	{
		if (a[i].y<=(h>>1))
		{
			int lst=i-1;
			while (!st1.empty())
			{
				node hh=st1.top();
				if (hh.y>=a[i].y) break;
				modify(1,1,n,hh.x,lst,hh.y-a[i].y);
				lst=hh.x-1;st1.pop();
			}
			if (lst!=i-1) st1.push((node){lst+1,a[i].y});
		}
		else
		{
			int lst=i-1;
			while (!st2.empty())
			{
				node hh=st2.top();
				if (hh.y<=a[i].y) break;
				modify(1,1,n,hh.x,lst,a[i].y-hh.y);
				lst=hh.x-1;st2.pop();
			}
			if (lst!=i-1) st2.push((node){lst+1,a[i].y});
		}
		st1.push((node){i,0});st2.push((node){i,h});
		modify(1,1,n,i,i,h-a[i].x);
		ans=max(ans,mx[1]+a[i+1].x);
	}
}

int main()
{
	w=rd();h=rd();n=rd();
	for (int i=1;i<=n;i++) a[i].x=rd(),a[i].y=rd();
	a[++n]=(node){0,0};a[++n]=(node){w,h};
	ans=0;
	gao();turn();gao();
	printf("%d\n",ans<<1);
	return 0;
}

Measured memory_bytes: 13260
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<deque>
#include<functional>
#include<ctime>
#include<cassert>
#include<cstring>
#include<unordered_map>
#include<cmath>
using namespace std;

#define sz(x) (int)(x.size())
#define fi(a,b) for(int i=a;i<=b;++i)
#define fj(a,b) for(int j=a;j<=b;++j)
#define fo(a,b) for(int o=a;o<=b;++o)
#define fdi(a,b) for(int i=a;i>=b;--i)
#define fdj(a,b) for(int j=a;j>=b;--j)
#define fdo(a,b) for(int o=a;o>=b;--o)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef double ld;
typedef vector<int> vi;

template<class T> bool uin(T &a, T b){ return (a > b ? a = b, true : false); }
template<class T> bool uax(T &a, T b){ return (a < b ? a = b, true : false); }

/////////////////////////////////

int const MAXN = 141;
ld const PI = acos(-1);

int n, x[MAXN], y[MAXN];
ld ans[MAXN];

ld norm(ld a) {
	while(a > PI * 2) {
		a -= PI * 2;
	}
	while(a < 0) {
		a += PI * 2;
	}
	return a;
}

ld getdist(ld a, ld b) {
	if (b >= a) {
		return b - a;
	}
	ld res = PI * 2 - a + b;
	return res;
}

void solve(){
	fi(0, n - 1) {
		vector<pair<ld, int>> a;
		fj(0, n - 1) {
			if (i == j) continue;
			ld ang = atan2( (ld) y[j] - y[i], (ld) x[j] - x[i] );
			ld a0 = norm(ang + PI / 2);
			ld a1 = norm(ang - PI / 2);
			a.pb(mp(a0, 1));
			a.pb(mp(a1, -1));
		}
		sort(a.begin(), a.end());
/*		for(pair<ld, int> z : a) {
			fprintf(stderr, "%.3lf %d\n", z.first, z.second);
		}
		cerr << '\n';*/
		int x, y, p = -1;
		fj(0, sz(a) - 1) {
			if (a[j].second == 1) {
				p = j;
				break;
			}
		}
		assert(p != -1);
		x = p;
		int q = 0;
		while(a[x].second == 1) {
			x = (x - 1 + sz(a)) % sz(a);
			q++;
		}
		y = (p + 1) % sz(a);
		while(a[y].second == 1) {
			q++;
			y = (y + 1) % sz(a);
		}
//		cerr << "x = " << x << " y = " << y << " q = " << q << endl << endl;
		if (q != n - 1) {
			continue;
		}
		ans[i] = getdist(a[(y - 1 + sz(a)) % sz(a)].first, a[y].first);
		ans[i] /= (PI * 2);
	}	
}

int main(){
#ifdef LOCAL
	freopen("input.txt","r",stdin);
//	freopen("output.txt","w",stdout);
#endif

	scanf("%d", &n);
	fi(0, n - 1) {
		scanf("%d %d", &x[i], &y[i]);
	}		
	solve();		
	fi(0, n - 1) {
		printf("%.15lf\n", ans[i]);
	}
	
#ifdef LOCAL
	fprintf(stderr, "ELAPSED TIME: %.3lf\n", (ld) clock() / CLOCKS_PER_SEC);
#endif	
	
	return 0;
}

Measured memory_bytes: 384
n, a, b = map(int, input().split())
s = input()

passed = 0
foreign = 0
for c in s:
    if c == "a":
        if passed < a + b:
            print("Yes")
            passed += 1
        else: print("No")
    elif c == "b":
        foreign += 1
        if passed < a + b and foreign <= b:
            print("Yes")
            passed += 1
        else: print("No")
    else:
        print("No")

Measured memory_bytes: 9232
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int V[100001] = {};
int M[12] = { 1,6,9,36,81,216,729,1296,6561,7776,46656,59049 };
int n, k;

int main()
{
	scanf("%d", &n);

	for (int i = 1; i <= n; ++i) {
		int min = 100;
		for (int j = 0; j < 12; ++j) {
			k = i - M[j];
			if (k < 0) break;			
			if (min > V[k])
				min = V[k];
		}
		V[i] = ++min;
	}

	printf("%d", V[n]);
	return 0;
}

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

using namespace::std;


int main()
{
	int N = 3;
	int M = 4;

	vector<int> A(N);
	vector<int> B(N);
	vector<int> C(M);

	for (int i = 0; i < N; i++) {
		cin >> A[i];
		cin >> B[i];
	}

	for (int m = 0; m < M; m++) {
		C[m] = 0;
	}

	for (int i = 0; i < N; i++) {
		C[A[i]-1] += 1;
		C[B[i]-1] += 1;
		//cout << A[i] << B[i] << C[0] << C[1] << C[2] << C[3] << endl;
	}

	for (int i = 0; i < M; i++) {
		if (C[i] == 0 || C[i] == 3) {
			cout << "NO" << endl;
			return 0;
		}
	}

	cout << "YES" << endl;

	
    return 0;
}


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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		if(a == 1) {
			System.out.println("Hello World");
		}else {
			int b = sc.nextInt();
			int c = sc.nextInt();
			System.out.println(b+c);
		}
	}

}


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

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define Decimal fixed << setpresicion(20)
#define SHOWP(x) cerr<<"["<<(x).FI<<", "<<(x).SE<<"]";
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}

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

int N, M;
vector<int> vv[2][110000];
bool used[2][110000];

void dfs(int now, int p)
{
  used[p][now] = true;
  for (auto& to : vv[p][now]) {
    if (!used[1 - p][to]) dfs(to, 1 - p);
  }
}

int main()
{
  cin >> N >> M;
  REP(i, N) {
    int K; cin >> K;
    REP(j, K) {
      int L; cin >> L;
      L--;
      vv[0][i].PB(L);
      vv[1][L].PB(i);
    }
  }

  dfs(0, 0);
  REP(i, N) {
    if (!used[0][i]) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;

  return 0;
}

Measured memory_bytes: 9344
def ss(n):
    return n / s(n)
def s(n):
    return sum([int(a) for a in str(n)])

K = int(input())
n = 0
d = 1
while K > 0:
    t1=ss(n+d)
    t2=ss(n+10*d)
    if t1 > t2:
        d *= 10
    n += d
    print(n)
    K -= 1


Measured memory_bytes: 3188
n=int(input())
a=[0]
b=[0]
c=[0]
for i in range(n):
    A,B,C=map(int, input().split())
    a.append(A)
    b.append(B)
    c.append(C)

dp=[[10**10,10**10,10**10] for i in range(n+1)]

dp[0][0]=0
dp[0][1]=0
dp[0][2]=0

dp[1][0]=a[1]
dp[1][1]=b[1]
dp[1][2]=c[1]

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

print(max(dp[n]))

Measured memory_bytes: 106632
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstdio>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <set>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> P;
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
const int MAXN = 100000;
const int MAXE = 100000;
const int MAXV = 10000;
const int inf = 1e9;
const ll INF = 2e18;
const ll MOD = 1e9 + 7;

struct UnionFind{
    vector<int> par,rank;
    UnionFind(int n):par(n),rank(n){
        for(int i=0;i<n;++i) par[i]=i;
    }
    int root(int x){
        if(par[x]==x) return x;
        return par[x]=root(par[x]);
    }
    void unite(int x,int y){
        int rx=root(x),ry=root(y);
        if(rx==ry) return ;
        if(rank[ry]>rank[rx]) par[rx]=ry;
        else par[ry]=rx;
        if(rank[rx]==rank[ry]) rank[rx]++;
    }
    bool same(int x,int y){
        return root(x)==root(y);
    }
};

vector<ll> fac,inv,finv;

void initcom(){
    fac=inv=finv=vector<ll>(1e6);
    fac[0]=fac[1]=1;
    inv[1]=1;
    finv[0]=finv[1]=1;
    for(ll i=2;i<1e6;++i){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}

ll com(int n,int k){
    if(n<0||k<0) return 0;
    if(n<k) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll x,ll y){
    if(y==0) return x;
    return gcd(y,x%y);
}
ll mopow(ll a,ll x,ll mod){
    ll res=1;
    while(x>0){
        if(x&1) res=res*a%mod;
        a=a*a%mod;
        x>>=1;
    }
    return res;
}

int main(){
    int n;cin>>n;
    int k=1;
    while(n>k*(k-1)/2) k++;
    if(n<k*(k-1)/2){
        cout<<"No"<<endl;
        return 0;
    }
    vector<vector<int> > ans(k);
    int c=1;
    for(int i=0;i<k;++i){
        for(int j=i+1;j<k;++j){
            ans[i].push_back(c);
            ans[j].push_back(c);
            ++c;
        }
    }
    cout<<"Yes"<<endl;
    cout<<k<<endl;
    for(int i=0;i<k;++i){
        cout<<k-1<<' ';
        for(int j=0;j<k-1;++j){
            cout<<ans[i][j];
            if(j<k-2) cout<<' ';
            else cout<<endl;
        }
    }
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> height(N);
  
  for(int i=0; i<N; i++){
    cin >> height.at(i);
  }
  
  int flag=0;
  
  for(int i=N-1; i>0; i--){
    if(height.at(i)<height.at(i-1)){
      height.at(i-1)--;
    }
    if(height.at(i)>=height.at(i-1)){
      flag=flag+1;
    }
  }
  
  if(flag==N-1){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
}

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

public class Main {
	public static void main(String args[]){
		BufferedReader insBR = new BufferedReader(new InputStreamReader(System.in));
		String strMessage = "";

		try{
			String[] strA = insBR.readLine().split(" ");
			int[] intA = new int[strA.length];
			for(int i = 0;i < strA.length ;i++){
				intA[i] = Integer.parseInt(strA[i]);
			}
			int intXR = intA[2] + intA[4];
			int intXR2 = intA[2] - intA[4];
			int intYR = intA[3] + intA[4];
			int intYR2 = intA[3] - intA[4];
			if(intXR <= intA[0] && 0 <= intXR2 && intYR <= intA[1] && 0 <= intYR2){
				strMessage = "Yes";
			}else{
				strMessage = "No";
			}
			System.out.println(strMessage);
		}catch(IOException e){
			System.out.println("入力が無効です。");
		}catch(NumberFormatException e){
			System.out.println("数値を入力してください。");
		}
	}

}



Measured memory_bytes: 24392
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    
    ll n, d; cin >> n >> d;
    
    ll ans = 0;
    zep(i, 0, n){
    	ll x, y; cin >> x >> y;
    	
    	if(x * x + y * y <= d * d)ans++;
    }
    print(ans)
    
    return 0;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <iostream>

using namespace std;

typedef long long ll;

int main( int argc, char **argv )
{
    ll N;
    cin >> N;

    ll res = 0;
    for ( ll a = 1; a * a <= N; a++ )
    {
        if ( N % a ) continue;

        ll m = ( N / a ) - 1;
        if ( m <= a ) continue;

        res += m;
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to;
	ld cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
bool suf(ld a, ld b, ld c, ld d) {
	if (b <= c || d <= a) return 0;
	return 1;
}//[a,b),[c,d)
ll fact(ll x, ll k) {//最大値、個数
	ll sum = 1;
	for (int i = 0; i < k; i++)
		sum *= (x--);
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res*x%p;
		x = x*x%p;
		n >>= 1;
	}
	return res;
}
#define int long long
const long long inf = 4523372036854775807;
const int iinf = 1500000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	int n, m;
	cin >> n >> m;
	int ans = n*m;
	if (n == 1)
		ans -= 2;
	else if (n == 2)
		ans = 0;
	else
		ans -= m * 2 - 2;
	if (m == 1)
		ans -= 2;
	else if (m == 2)
		ans = 0;
	else
		ans -= n * 2 - 2;
	if (n + m == 2)
		cout << 1 << endl;
	else
		cout << max(0ll, ans) << endl;
	getchar(); getchar();
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,(e))
#define irp(i,s,e) for(int i=(s);i>(e);--i)
#define irpz(i,s) irp(i,(s),-1)
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;}
template<class T> T in(){T x;cin>>x;return x;}
template<class T> vector<T> inarr(int s,int e, T init=0){
	vector<T> v;T x;
	for(int i=0;i<s;++i)v.push_back(init);
	for(int i=s;i<e;++i){x=in<T>();v.push_back(x);}
	return v;
}
int N,K;

ll solve(){
	ll ans = 1;
	rp(i,0,N){
		if(ans*2 < ans+K) ans*=2;
		else ans +=K;
	}
	return ans;
}

int main(){
	cin>>N;
	cin>>K;
	cout<< solve() <<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char a[1000];
char b[1000];
int main()
{
    scanf("%s",a);
    scanf("%s",b);
    int k=0;
    while(k<strlen(a)&&k<strlen(b))
    {
        cout<<a[k]<<b[k];
        k=k+1;
    }
    if (strlen(a)>strlen(b)) cout<<a[strlen(a)-1];
    cout<<endl;
    return 0;
}

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


int main() {

	int64_t n;
	cin >> n;


    uint64_t minimum = 100;
    vector<int64_t> divisor;
    for(int64_t i=1;i*i<=n;i++){
        if(n%i==0){
            string wk1,wk2;
            wk1 = to_string(i);
            wk2 = to_string(n/i);
            minimum = min(max((uint64_t)wk1.size(),(uint64_t)wk2.size()),minimum);
        }
    }

    cout<<minimum<<endl;

	return 0;
}

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

#define FOR(i,S,E) for(int i=S; i<E; i++)
#define ri(x) scanf("%d", &x)
const int MAXN = 1e2+2;
int vis[MAXN];
int main() {
	int N;
	ri(N);
	int count=0;
	FOR(i,0,N) {
		int inp;
		ri(inp);
		if (!vis[inp]) {
			count++;
			vis[inp]=1;
		}
	}
	printf("%d\n", count);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <atcoder/all>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

const long long INF = 1e18;
//const ll mod = 1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll ans = 0;
    for(ll i = 1; i <= N; i++) {
        ans += (N - 1) / i;
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
	int n;
	while(cin >> n && n != -1 ){
		if( n == 0 ) cout << 0 << endl;
		else{
			string s;
			while(n){
				s += n % 4 + '0';
				n /= 4;
			}
			for(int i = s.size()-1 ; i >= 0 ; i--)
				cout << s[i];
			cout << endl; 
		}
	}
}

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

int main(){
vector<int>vec = {1,1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int k;
cin>>k;
cout<<vec.at(k-1)<<endl;
}



Measured memory_bytes: 256
// https://atcoder.jp/contests/abc175/tasks/abc175_d
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)

void solve() {
    int N, K;
    cin >> N >> K;
    vector<int> P(N), C(N);
    REP(i, N) cin >> P[i], P[i]--;
    REP(i, N) cin >> C[i];

    int ans = -1e12;
    // スタート位置
    REP(i, N) {
        vector<int> v;
        int now = i;
        while (true) {
            now = P[now];
            v.emplace_back(C[now]);
            if (now == i) {
                break;
            }
        }
        int loopSum = accumulate(ALL(v), 0LL);
        int cnt = v.size();
        int t = 0;
        REP(j, min(cnt, K)) {
            t += v[j];
            // ループ内の合計x残りループ回数を加算する
            // ループ内の合計が負なら無視
            ans = max(ans, t + max(0LL, loopSum) * ((signed)(K - j - 1) / cnt));
        }
    }
    cout << ans << endl;
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


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

const int N = 100010, mod = 1e9 + 7;

int sum[N << 2];

inline void Inc(int &x, int y) {
	x += y, x -= x >= mod ? mod : 0;
}

void update(int rt, int l, int r, int x, int y) {
	Inc(sum[rt], y);
	if (l == r) return;
	int mid = (l + r) >> 1;
	if (x <= mid) update(rt << 1, l, mid, x, y);
	else update(rt << 1 | 1, mid + 1, r, x, y);
} 

int query(int rt, int l, int r, int start, int end) {
	if (start <= l && r <= end) return sum[rt];
	int res = 0, mid = (l + r) >> 1;
	if (start <= mid) Inc(res, query(rt << 1, l, mid, start, end));
	if (end > mid) Inc(res, query(rt << 1 | 1, mid + 1, r, start, end));
	return res;
}

int x[N], y[N], val[N], tot;

struct Point {
	int x, y;
} p[N];

int main() {
	int n, m; scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++) scanf("%d", &x[i]);
	for (int i = 1; i <= m; i++) scanf("%d", &y[i]);
	sort(y + 1, y + m + 1); int all = 0;
	for (int i = 1; i <= n; i++) {
		int a = lower_bound(y + 1, y + m + 1, x[i]) - y;
		if (a > m || a == 1) continue;
		p[++all] = (Point){x[i] - y[a - 1], y[a] - x[i]}, val[++tot] = y[a] - x[i];
	}
	sort(val + 1, val + tot + 1), tot = unique(val + 1, val + tot + 1) - val - 1; 
	sort(p + 1, p + all + 1, [](Point a, Point b){
		if (a.x == b.x) return a.y > b.y;
		return a.x < b.x;
	});
	update(1, 0, tot, 0, 1);
	for (int i = 1; i <= all; i++) {
		p[i].y = lower_bound(val + 1, val + tot + 1, p[i].y) - val;
		if (i && p[i].x == p[i - 1].x && p[i].y == p[i - 1].y) continue;
		update(1, 0, tot, p[i].y, query(1, 0, tot, 0, p[i].y - 1));
	}
	printf("%d\n", query(1, 0, tot, 0, tot));
}


Measured memory_bytes: 2816
#include <iostream>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <numeric> // accumulate(begin,end,初期値)
#include <string>

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<x<<endl
#define rep(i,n) for(int i = 0;i < (n);++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0)

const ll INF = 1e9+7;

// 各桁の和
template<typename T>T digit(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;}
template<typename T>T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}

int main() {
  int n;cin>>n;
  string s;cin>>s;
  if(n >= 3200)print(s);
  else print("red");
  return 0;
}

Measured memory_bytes: 256
//BROWNIE TK

#include <bits/stdc++.h>
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;

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

#define pb push_back
#define popb pop_back()
#define pf push_front
#define popf pop_front()
#define si size()
#define be begin()
#define en end()
#define all(v) v.be, v.en
#define le length()
#define mp make_pair
#define mt make_tuple
#define F first
#define S second

#define forz(i, n) for (int i = 0; i < n; i++)
#define forzm(i, m, n) for (int i = m; i < n; i++)
#define rforz(i, n) for (int i = n - 1; i >= 0; i--)
#define rforzm(i, m, n) for (int i = n - 1; i >= m; i--)
#define deci(n) fixed << setprecision(n)
#define high(n) __builtin_popcount(n)
#define parity(n) __builtin_parity(n)
#define ctz(n) __builtin_ctz(n)
#define lb lower_bound
#define ub upper_bound
#define er equal_range
#define maxe *max_element
#define mine *min_element
#define mod 1000000007
#define mod2 998244353
#define kira ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)

#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl

#define oset tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define osetlli tree<lli, null_type, less<lli>, rb_tree_tag, tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set
#define ofk order_of_key
#define fbo find_by_order
using namespace std;

/*STD fucntions*/
lli power(lli x, lli y, lli p)
{
    lli res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        //y must be even now
        y = y >> 1; //y=y/2
        x = (x * x) % p;
    }
    return res;
}
lli gcd(lli a, lli b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
lli lcm(lli a, lli b)
{
    return a * b / gcd(a, b);
}
lli modi(lli a, lli m)
{
    // fermat little thm where m is prime
    return power(a, m - 2, m);
}
/*CODE BEGINS*/
lli cnt[200005] = {0};
bool vis[200005];
vector<lli> adj[200005];
lli ans = 0;
void dfs(int s)
{
    if (vis[s])
        return;
    vis[s] = true;
    //tala
    for (auto u : adj[s])
    {
        if (!vis[u])
            cnt[u] += cnt[s];
        dfs(u);
    }
}
int main()
{
    kira;
    lli n, q;
    cin >> n >> q;
    lli a, b;
    forz(i, n - 1)
    {
        cin >> a >> b;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    lli p, x;
    forz(i, q)
    {
        cin >> p >> x;
        cnt[p] += x;
    }
    dfs(1);
    for (int i = 1; i <= n; i++)
        p0(cnt[i]);
    return 0;
}

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

using namespace std;

#define int long long

constexpr int INF = 1LL << 60;

constexpr int MAX_N = 200000;
constexpr int MAX_B = 100005;

typedef pair<int, int> pii;

int n, a[MAX_N], b[MAX_N], sumB[MAX_B], sumA[MAX_B], imos[MAX_B];

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

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

        sumB[b[i]]++;
        sumA[a[i]]++;

        imos[a[i]]++;
        imos[b[i]]--;
    }

    int ans2 = 0;
    for (int i = 1; i < MAX_B; i++)
    {
        sumB[i] += sumB[i - 1];
        sumA[MAX_B - i - 1] += sumA[MAX_B - i];

        imos[i] += imos[i - 1];
        ans2 = max(ans2, imos[i]);
    }

    int ans1 = 0;
    for (int i = 0; i < n; i++)
    {
        ans1 = max(ans1, n - sumB[a[i]] - sumA[b[i]]);
    }

    cout << ans1 << " " << ans2 << endl;
}



Measured memory_bytes: 8624
#include<iostream>
#include<utility>
using namespace std;
int main(){
    
    while(1){
        int x,y;
        cin>>x>>y;
        if(x>y){
            swap(x,y);
        }
        if(x==0&&y==0)break;
        cout<<x<<" "<<y<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 3044
#include <iostream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <string>
#include <vector>
using ll = long long;
using namespace std;
int main()
{
    int N;
    cin >> N;
    ll ans = 0;
    for (int i = 1; i <= N; i ++) {
        for (int j = 1; j <= i; j ++){
            for (int l = 1; l <= j; l ++){
                int temp = __algo_gcd(i,__algo_gcd(j,l));
                if(i != j && j != l)     ans += temp * 6;
                else if (i == j && j == l)  ans += temp;
                else    ans += temp * 3;
            }
        }
    }
    cout << ans << endl;
}
    


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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n, m) for (int (i) = (n); (i) < (m); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};

int n, W;
int weight[110], value[110];
int dp[110][10010]; // DPテーブル

int main() {
   cin >> n >> W;
   rep (i, 0, n) {
      cin >> value[i] >> weight[i];
   }

   // DP初期条件: dp[0][w] = 0
   rep (w, 0, W+1) {
      dp[0][w] = 0;
   }

   rep (i, 0, n) {
      rep (w, 0, W+1) {
         if (w >= weight[i]) {
            dp[i+1][w] = 
               max(dp[i][w-weight[i]] + value[i], dp[i][w]);
         } else {
            dp[i+1][w] = dp[i][w];
         }
      }
   }

   cout << dp[n][W] << endl;

   return 0;
}


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

int main() {
  int N;
  cin>>N;
  vector<int> v(N);

  int m=0;
  int a=1;
  rep(i,N){
    cin>>v.at(i);
    if(m<v.at(i)){
      m=v.at(i);
    }
  }
  int n=0;
  
  rep(j,N){
  rep(i,N){
    if(v.at(i)<m){
      if(n<v.at(i)){
        n=v.at(i);
      }
    }
  }
  if(0!=n){
    m=n;
    a++;
  }
  n=0;
  }
  
  cout<<a<<endl;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>
#define endl '\n'
#define ll long long
#define mod 1000000007
#define NCONS 1000000000
//#define NCONS 100001
//#define NCONS 1001
//#define NCONS 101
#define MCONS 2001
#define LIMIT 1000000000
#define TRUE 1
#define FALSE 0
#define toRadian(degree) ((degree) * (M_PI / 180.))
#define toDegree(radian) ((radian) * (180. / M_PI))
using namespace std;
struct Point{int x; int y;};

int main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    
    int k; cin >> k;
    int odd = k / 2, even = k / 2;
    if(k % 2 == 1) odd += 1;
    
    cout << odd * even << endl;
    
    
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;
int main()
{
    int n, m; cin>>n>>m;
    if(m==1){
        cout<<4<<endl;
        return 0;
    }
    ll p2[6001]; p2[0]=1;
    for(int i=1; i<=2*m; i++) p2[i]=p2[i-1]*2%MOD;
    if(n==1){
        cout<<p2[m-1]*4%MOD<<endl;
        return 0;
    }
    ll comb[3001][3001];
    comb[0][0]=comb[1][0]=comb[1][1]=1;
    for(int i=2; i<=m; i++){
        comb[i][0]=comb[i][i]=1;
        for(int j=1; j<i; j++){
            comb[i][j]=(comb[i-1][j-1]+comb[i-1][j])%MOD;
        }
    }
    ll dp[3001][3001]={}, dp2[3001][3001]={};
    dp[0][0]=1; dp2[0][0]=1;
    for(int i=0; i<m-1; i++){
        for(int j=0; j<m; j++){
            if(j>0){
                dp[i+1][j-1]+=dp[i][j]; dp[i+1][j-1]%=MOD;
            }
            if(j<n-1){
                dp[i+1][j+1]+=dp[i][j]; dp[i+1][j+1]%=MOD;
            }
        }
    }
    for(int i=0; i<m-1; i++){
        for(int j=0; j<m; j++){
            if(j>0){
                dp2[i+1][j-1]+=dp2[i][j]; dp2[i+1][j-1]%=MOD;
            }
            if(j<n-2){
                dp2[i+1][j+1]+=dp2[i][j]; dp2[i+1][j+1]%=MOD;
            }
        }
    }
    ll s[3001]={}, s2[3001]={};
    for(int i=0; i<m; i++){
        for(int j=0; j<m; j++){
            s[i]+=dp[i][j]; s[i]%=MOD;
            s2[i]+=dp2[i][j]; s2[i]%=MOD;
        }
    }
    ll ct[3001]; ct[0]=1;
    for(int i=1; i<m; i++){
        ct[i]=s[i];
        for(int j=0; j<i; j++){
            ct[i]+=s[j]*s2[i-1-j];
            ct[i]%=MOD;
        }
    }
    ll ans=0;
    for(int i=0; i<m; i++){
        ans+=(comb[m-1][i]*p2[m-1-i]%MOD*ct[i]%MOD);
        ans%=MOD;
    }
    ans*=4; ans%=MOD;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 211456
# -*- coding:utf-8 -*-

def solve():
    N = int(input())
    MOD = 10**9+7
    ans = pow(10,N,MOD)
    ans = (ans - (2*pow(9,N,MOD))%MOD)%MOD
    ans = (ans + pow(8,N,MOD))%MOD
    print(ans)


if __name__ == "__main__":
    solve()


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

int main(){
 
  int a,b ; cin >> a >> b ;
  a == 1 ? a = 14 : a = a ;
  b == 1 ? b = 14 : b = b ;
  
  if ( a > b ) cout << "Alice";
  else if ( b > a ) cout << "Bob";
  else cout << "Draw" ;
  
  
  
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
typedef long long ll;
int main() {
	char a;
	cin >> a;
	if (a == 'a' || a == 'i' || a == 'u' || a == 'e' || a == 'o')
		cout << "vowel" << endl;
	else cout << "consonant" << endl;
}

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

int sum[101];
int main() {
    int N;
    cin >> N;
    int MAX_P = -1;
    for(int i=0;i<N;i++){
        int p; cin >> p;
        sum[p]++;
        MAX_P = max(MAX_P, p);
    }

    for(int i=MAX_P -1;i>=0;i--) sum[i] += sum[i+1];

    int ans = 0;
    for(int i=0;i<=MAX_P;i++){
        if(sum[i] >= i) ans = i;
    }

    cout << ans << endl;
}


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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --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; }

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

int main(){
    int N;
    cin >> N;

    set<int> S;
    rep(i, N) {
        int a;
        cin >> a;
        if (S.find(a) == S.end()) S.insert(a);
        else S.erase(a);
    }

    cout << S.size() << endl;
}

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

typedef long long int ll;

int main()
{
    ll n, k, ans;
    cin >> n >> k;

    if(k % 2 != 0){
        ll t = 0, tk = 0;
        for(ll i = 1;i <= n;i++){
            if(i % k == 0){
                t++;
            }
        }
        ans = pow(t, 3);
    }
    else{
        ll t = 0, tk = 0;
        for(ll i = 1;i <= n;i++){
            if(i % k == 0){
                tk++;
            }
            else if(i % (k / 2) == 0){
                t++;
            }
        }
        ans = pow(t, 3);
        ans += pow(tk, 3);
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 640
n, a, b = map(int, input().split())
if (b - a) % 2 == 0:
  print((b - a)//2)
else:
  print(
    min(
      b-1,
      n-a,
      (a-1)+1+(b-(a-1)-1)//2, 
      (n-b)+1+(n-(a+(n-b)+1))//2
    )
  )

Measured memory_bytes: 2940