akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main()
{
    char ch[51][51];
    int count,i,j,H,W;
    scanf("%d %d",&H,&W);
    ch[0][0]=getchar();
    for(i=0;i<H;i++)
    {
        for(j=0;j<W;j++)
            scanf("%c",&ch[i][j]);
        ch[i+1][0]=getchar();
    }
    for(i=0;i<H;i++)
    {
        count=0;
        for(j=0;j<W;j++)
        {
            count=0;
            if(ch[i][j]=='.')
            {
                if(ch[i-1][j]=='#')
                   count++;
                if(ch[i-1][j+1]=='#')
                   count++;
                if(ch[i][j+1]=='#')
                   count++;
                if(ch[i+1][j+1]=='#')
                   count++;
                if(ch[i+1][j]=='#')
                   count++;
                if(ch[i+1][j-1]=='#')
                   count++;
                if(ch[i][j-1]=='#')
                   count++;
                if(ch[i-1][j-1]=='#')
                   count++;
                ch[i][j]=count+'0';
            }
        }
    }
    for(i=0;i<H;i++)
    {
        for(j=0;j<W;j++)
        {
            printf("%c",ch[i][j]);
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fod(i,a,b) for(int i=a;i>=b;i--)
#define me0(a) memset(a,0,sizeof(a))
#define me1(a) memset(a,-1,sizeof(a))
#define op freopen("in.txt", "r", stdin)
#define pii pair<int,int>
#define mp(x,y) make_pair(x,y)
using namespace std;
const int INF = 0x3f3f3f3f;
typedef unsigned long long ULL;
typedef long long LL;
void read(int& val) { int x = 0; int bz = 1; char c; for (c = getchar(); (c<'0' || c>'9') && c != '-'; c = getchar()); if (c == '-') { bz = -1; c = getchar(); }for (; c >= '0' && c <= '9'; c = getchar()) x = x * 10 + c - 48; val = x * bz; }
const int mod=1e9+7;
const int maxn = 1e6+11;

LL f[maxn];
void init(){
    f[0]=1;
    fo(i,1,maxn-1){
        f[i]=f[i-1]*i%mod;
    }
}
LL ksm(LL a,LL b){
    LL res=1;
    while(b){
        if(b&1){
            res = res*a%mod;
        }
        a=a*a%mod;
        b>>=1;
    }
    return res;
}
LL p(int a,int b){
    return f[b]*ksm(f[b-a],mod-2)%mod;
}
LL c(int a,int b){
    return f[b]*ksm(f[b-a]*f[a]%mod,mod-2)%mod;
}

int n,m;
int main(){
//    op;
    read(n);read(m);
    init();
    LL ans=0;
    fo(i,0,n){
        LL res1 = p(i,m),res2 = p(n-i,m-i);
        ans += c(i,n)*res1%mod*res2%mod*res2%mod*pow(-1,i);
        ans%=mod;
    }
    ans=(ans+mod)%mod;
    printf("%lld\n",ans);


    return 0;
}

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

#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descsort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

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

    cout<<s.substr(0,4)<<" "<<s.substr(4,8)<<endl;
    return 0;
}

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

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

int main()
{
    int a,b;
    cin >> a >> b;
    
    
    if (a*b%2==1) {
        cout << "Odd" << endl;
    }
    else
    {
        cout << "Even" << endl;
    }
    
    return 0;
}

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

typedef long long LL;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
typedef vector<pii> vpi;
typedef vector<pll> vpl;

#define fast ios_base::sync_with_stdio(0),cin.tie(0)
#define temp template<typename T>
#define debug(x) cerr<<"Line "<<__LINE__<<": "<<#x<<" = "<<x<<'\n'
#define itr(it,x) for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define rep(i,a,b) for(int i=a;i<=(int)b;i++)
#define repr(i,a,b) for(int i=a;i>=(int)b;i--)
#define cas(n) printf("Case %d:",(int)n)
#define mem(x,v) memset(x,v,sizeof(x))
#define read(x) freopen(x,"r",stdin)
#define write(x) freopen(x,"w",stdout)
#define all(x) x.begin(),x.end()
#define aut(x,v) for(auto &x:v)
#define ini(n) scanf("%d",&n)
#define inl(n) scanf("%lld",&n)
#define ind(n) scanf("%lf",&n)
#define ins(n) scanf("%s",n)
#define insn(n) scanf(" %[^\n]",n)
#define outi(n) printf("%d",(int)n)
#define outl(n) printf("%lld",(LL)n)
#define outd(n,p) printf("%.*lf",p,(double)n)
#define outs(n) printf("%s",n)
#define sz(x) (int)x.size()
#define nl printf("\n")
#define sp printf(" ")
#define pb push_back
#define mp make_pair
#define xx first
#define yy second

const int inf=0x3f3f3f3f;
const int mod=1000000007;
const int mx=10000005;
const LL  infL=0xf3f3f3f3f3f3f3f;
const double eps=1e-9;
const double pi=acos(-1.0);

int main()
{
    //read("in.txt"),write("out.txt");
    int n,p;
    double t,x;
    ini(n),ind(t),ind(x);
    double a[n];
    rep(i,0,n-1)
    ind(a[i]),a[i]=t-.006*a[i];
    double mnn=inf*1.0;
    rep(i,0,n-1)
    if(abs(x-a[i])<mnn)
    {
        mnn=abs(x-a[i]);
        p=i+1;
    }
    outi(p),nl;
    return 0;
}



Measured memory_bytes: 256
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
count = Counter(A)
keys = list(count.keys())
keys.sort(reverse = True)
a = 0
b = 0
for k in keys:
    if a == 0:
        if count[k] >= 4:
            a = b = k
            break
        elif count[k] >= 2:
            a = k
    else:
        if count[k] >= 2:
            b = k
            break
print(a * b)

Measured memory_bytes: 18600
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

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

#include <stdio.h>

int main()
{
    int N, M;

    scanf("%d %d", &N, &M);
    int a, b;

    set<int> r1;
    set<int> r2;

    REP(i, M)
    {
        scanf("%d %d", &a, &b);

        if (a == 1) {
            r1.insert(b);
        } else if (b == N) {
            r2.insert(a);
        }
    }

    vector<int> ret;

    set_intersection(begin(r1), end(r1), begin(r2), end(r2), back_inserter(ret));

    for(auto i: ret) {
      cerr << i << endl;
    }
    if (ret.size() > 0) {
      cout << "POSSIBLE" << endl;
    } else {
      cout << "IMPOSSIBLE" << endl;
    }
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define fo(i,n)         for(int i=0;i<n;i++)
#define Fo(i,k,n)       for(int i=k;i<n;i++) 
#define endl            "\n"
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define vec(x)          vector<x>
#define matrix(x)       vector<vector<x>>
#define mem(a,b)        memset(a, b, sizeof a)
#define vii             vector<pair<int,int>>
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define MOD             998244353
#define deb(x)          cerr <<#x<<" = "<<x<<"\n"
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(v)          v.begin(),v.end()
#define rep(i,a,b)      for (int i = a; i<b; ++i)
#define len(s)          s.length()
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
 
int power(int a,int b,int m=mod)
{int ans=1;while(b>0){if(b&1)ans=(ans*a)%m;a=(a*a)%m;b>>=1;}
return ans;}

void angshuGod()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

const int N = 1e5+1;
const double pi = acos(-1);

void solve(){    

    int s,w;
    cin>>s>>w;
    if(w>=s) cout<<"unsafe";
    else cout<<"safe";
    
}

 
int32_t main()
{
    angshuGod();

    int t;

    t = 1;
    //cin>>t;

    while(t--){
        solve();
    }
    
    return 0;
}

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

public class Main {
	static Scanner sc = new Scanner(System.in);
	static int[] a = new int[6];
//	static int[] b = new int[3];
	static int[] town = new int[5];
	public static void main(String[] args) {
		for (int i = 0; i < a.length; i++) {
			a[i] = Integer.parseInt(sc.next());
//			b[i] = Integer.parseInt(sc.next());
		}
		Arrays.sort(a);
		for (int i : a) {
			town[i]++;
		}
		boolean ans = true;
		for (int i : town) {
			if (i == 3) {
				ans = false;
			}
		}
//		System.out.println(Arrays.toString(a));
//		System.out.println(Arrays.toString(town));
		if (ans) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}

}

Measured memory_bytes: 22740
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();
        int red =0;
        for(char x: S.toCharArray()){
            if ('R' == x)
                red++;
        }
        if (red * 2> N)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}


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

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

  int homework_days = N;

  for(int i=0; i<M; i++){

    int a;
    cin >> a;
    homework_days -= a;

    if( homework_days < 0 ){
      printf("%d\n", -1 );
      return 0;
    }

  }

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

  return 0;

}

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

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

using ll = long long;
using pll = pair<ll, ll>;

int main()
{
    ll x;
    cin >> x;

    cout << (x == 0 ? 1 : 0) << endl;

    return 0;
}


Measured memory_bytes: 3620
s=input()
a=0
now=1
l=[0]*2019
for i in list(s)[::-1]:
    a=(a+now*int(i))%2019
    l[a]+=1

    now*=10
    now%=2019
ans=0
for i in l:
    ans+=(i-1)*i//2
print(ans+l[0])

Measured memory_bytes: 12172
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func maxProfit(r []int) int {
	ans := math.MinInt32
	minVal := math.MaxInt32

	for i := 0; i < len(r); i++ {
		if r[i]-minVal > ans {
			ans = r[i] - minVal
		}
		if r[i] < minVal {
			minVal = r[i]
		}
	}
	return ans
}

func main() {
	//sc.Split(bufio.ScanWords)

	n := nextInt()
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	fmt.Println(maxProfit(r))

}



Measured memory_bytes: 5404
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = s_inpl()   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = inpl()	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

import math
import copy
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
from bisect import bisect_left, bisect_right
# import numpy as np

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]

def i_inpl(): return int(input())
def s_inpl(): return map(int,input().split())
def l_inpl(): return list(map(int, input().split()))
INF = float("inf")

#############################################

N = int(input())
reds = [ l_inpl() for _ in range(N)]
blues = [ l_inpl() for _ in range(N)]

reds.sort(key=lambda a:a[1], reverse=True)
blues.sort()


ans = 0
for b_ind in range(N):
    bx, by = blues[b_ind][0], blues[b_ind][1]
    for r_ind in range(len(reds)):
        rx, ry = reds[r_ind][0], reds[r_ind][1]
        if rx < bx and ry < by:
            reds.remove([rx, ry])
            ans += 1
            break

print(ans)


Measured memory_bytes: 3668
import std.stdio, std.conv, std.algorithm, std.range, std.array, std.string, std.uni, std.bigint, std.math;

void main() {
  auto n = readln.chomp.to!uint;
  auto an = readln.split.to!(long[]);
  min(func(an, 0), func(an, 1)).writeln;
}

ulong func(long[] an, uint mod) {
  long sum = 0;
  ulong res = 0;
  foreach(i,a; an) {
    sum += a;
    if (i % 2 == mod && sum <= 0) {
      res += 1 - sum;
      sum = 1;
    }
    if (i % 2 != mod && sum >= 0) {
      res += 1 + sum;
      sum = -1;
    }
  }
  return res;
}


Measured memory_bytes: 4488
#include <bits/stdc++.h>
using namespace std;
#include<chrono>
#define ll long long
#define ld long double
#define eb emplace_back
#define pb push_back
#define mt make_tuple
#define tc  ll t; cin>>t; while(t--)
#define io ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define F first
#define S second
#define vi vector<ll>
#define pii pair<ll,ll>
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define vii vector<pair<ll,ll>>
ll gcd(ll n,ll m)
{
    if(n==0)
            return m;
    return gcd(m%n,n);
}
bool ifprime(ll n)
{
if(n==1)
return false;
    ll i;
for(i=2;i*i<=n;i++)
{
if(n%i==0)
return false;
 
}
return true;
}
void disp(vi v)
{
    for(auto u:v)
    cout<<u<<" ";
    cout<<"\n";
}
void remleadzero(vector<int> &v)
{
    vector<int> u;
    int i=0;
    while(v[i]==0)
        i++;
    while(i<v.size())
    {
        u.push_back(v[i]);
        i++;
    }
    v=u;
}
#define mod 1000000007LL
/*
void myscanf(long long *n)
{
    register long long c=getchar_unlocked();
    *n=0;
    for(;(c<48 ||c>57);c=getchar_unlocked())
        ;
    for(;(c>47 && c<58);c=getchar_unlocked())
    {
        *n=(*n<<1)+(*n<<3)+(c&15);
    }
 
}
void fastscan(long long &number)
{
    bool negative = false;
    register long long c;
 
    number = 0;
 
    c = getchar_unlocked();
    if (c=='-')
    {
 
        negative = true;
 
        c = getchar_unlocked();
    }
 
 
    for (; (c>47 && c<58); c=getchar_unlocked())
        number = number *10 + c - 48;
 
 
    if (negative)
        number *= -1;
}
*/
ll fast_expo(ll n,ll m, ll md)
{
    ll a=1;
    while(m>0)
    {
        if(m&1) a=(a*n)%md;
        n=(n*n)%md;
        m/=2;
    }
    return a%md;
}
long long sqroot(long long n){
    long double N = n;
    N = sqrtl(N);
    long long sq = N-2;
    sq = max(sq,0LL);
    while(sq*sq<n){
        sq++;
    } 
    if((sq*sq)==n)
        return sq;
    return -1;
}

int dp[10004],a[1005],b[1005], mx,n;

int cost(int h){
    if(h<=0)
        return 0;
    if(dp[h]!=-1)
        return dp[h];
    int ret = 1e9;
    for(int i=0;i<n;i++){
        ret = min(ret, b[i]+cost(h-a[i]));
    }   
    dp[h] = ret;
    return ret;
}

int main()
{
    io;
    int h;
    mx = 1e9;
    cin>>h>>n;
    int used[1005]{};
    pair<int,int> p[n];
    map<int,int> mp;
    mp.clear();
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];

     }
     memset(dp,-1,sizeof(dp));
    cout<<cost(h);
    // for(int i=0;i<n;i++){
    //     for(int j=0;j<h;j++)
    //         cout<<dp[i][j]<<' ';
    //     cout<<'\n';
    // }
    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }

int main(){
    INT(n);
    vector<int> vec(n);
    in(vec);
    sort(all(vec));
    ll ans=0;
    if(n%2==1){
        if(vec[0]!=0)goto skip;
        for(int i=1;i<n;i++){
            if(vec[i]!=i+(i%2))goto skip;
        }
    }else{
        for(int i=0;i<n;i++){
            if(vec[i]!=i+(i%2==0))goto skip;
        }
    }
    ans=modpow((ll)2,(ll)n/2,(ll)MOD);
    skip:out(ans);
}

Measured memory_bytes: 3780
#include<stdio.h>
int main(void)
{
  int a,b,c;
  int tmp;
  
  scanf("%d %d %d",&a,&b,&c);
  tmp=a;
  a=b;
  b=tmp;
  tmp=a;
  a=c;
  c=tmp;
  printf("%d %d %d\n",a,b,c);
  return 0;
}

Measured memory_bytes: 128
import java.util.* ;
class Main {
  public static void main(String[] args) {
    
    Scanner scan = new Scanner(System.in);

	int a = scan.nextInt();
    int b = scan.nextInt();
    
    
    int x = Math.max(a-b , a+b);
    int y = Math.max(x,a*b);
    System.out.println(y);
    
  }
}


Measured memory_bytes: 22868
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,w) for (int i = 0;i < (w); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int INF = 1e9;

int main(){
  int n,q;
  string s;
  cin >> n >> s >> q;
  vector<set<int>> table(26);
  rep(i,s.size()) table[s[i]-'a'].insert(i);
  rep(query,q){
    int com;cin >> com;
    if(com == 1){
      int i;
      char ch;
      cin >> i >> ch;
      --i;
      table[s[i]-'a'].erase(i);
      s[i] = ch;
      table[ch-'a'].insert(i);
    }else{
      int ans = 0;
      int l,r;cin >> l >> r;
      --r;--l;
      rep(j,26){
        set<int>::iterator it = table[j].lower_bound(l);
        if(it != table[j].end() && *it <= r) ans++;
      }
      printf("%d\n",ans);
    }
  }
}

Measured memory_bytes: 27232
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

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

	
	int A[3];
	cin >> A[0] >> A[1] >> A[2];
	sort(A, A + 3);

	if (A[0] == 5 && A[1] == 5 && A[2] == 7) co("YES");
	else co("NO");

	Would you please return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
Q = int(input())

A.sort()
s = sum(A)
A_dict = dict()
A_dict[A[0]] = 1
for i, value in enumerate(A):
    if i == 0: continue
    bA = A[i-1]
    if value == bA:
        A_dict[A[i]] += 1
    else:
        A_dict[A[i]] = 1

# print(A_dict)

for i in range(Q):
    B, C = map(int, input().split())
    if B in A_dict:
        s += (C - B) * A_dict[B]
        if C in A_dict:
            A_dict[C] += A_dict.pop(B)
        else:
            A_dict[C] = A_dict.pop(B)
    print(s)


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

int main() {
 
  int N;
  cin >> N;
  
  vector<int> a(N);
  for(int i=0; i<N; i++){
    cin >> a.at(i);
  }
  
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  
  int alice = 0, bob = 0;
  for(int i=0; i<N; i+=2){
    alice += a.at(i);
  }

  for(int i=1; i<N; i+=2){
    bob += a.at(i);
  }
  
  cout << alice - bob << endl;
  
}


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

#define pb push_back
#define ff first
#define ss second

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

const ll MAXN = 4 * 100 * 1000 + 17, mod = 998244353;

int sum(int a, int b) {
	a += b;
	if (a >= mod)
		a -= mod;
	else if (a < 0)
		a += mod;
	return a;
}

int mul(int a, int b) {
	return (1LL * a * b) % mod;
}

int pw(int a, int b) {
	int res = 1;
	while (b) {
		if (b & 1)
			res = mul(res, a);
		a = mul(a, a);
		b >>= 1;
	}
	return res;
}

ll n, a, b, k, fac[MAXN], ifac[MAXN], ans;

void prep() {
	fac[0] = 1;
	for (int i = 1; i < MAXN; i++)
		fac[i] = mul(fac[i - 1], i);
	for (int i = 0; i < MAXN; i++)
		ifac[i] = pw(fac[i], mod - 2);
}

int C(int x, int y) {
	return mul(fac[x], mul(ifac[y], ifac[x - y]));
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> a >> b >> k;
	prep();
	for (int i = 0; i <= n; i++) {
		ll kp = k - i * a;
		if (kp >= 0 && kp % b == 0 && kp / b <= n)
			ans = sum(ans, mul(C(n, i), C(n, kp / b)));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6528
s=input().split()
N=int(s[0])
C=int(s[1])
d=[]
for i in range(C):
    s=input().split()
    temp=[]
    for item in s:
        temp.append(int(item))
    d.append(temp)
if N==1:
    print("0")
else:
    c=[[],[],[]]
    cost=[[],[],[]]
    for j in range(N):
        s=input().split()
        for i in range(len(s)):
            c[(i+j)%3].append(int(s[i])-1)
    for i in range(C):
        s=0
        for col in c[0]:
            s+=d[col][i]
        cost[0].append((s,i))
        s=0
        for col in c[1]:
            s+=d[col][i]
        cost[1].append((s,i))
        s=0
        for col in c[2]:
            s+=d[col][i]
        cost[2].append((s,i))
    res=100000000000
    for i in range(C):
        for j in range(C):
            for k in range(C):
                if cost[0][i][1]!=cost[1][j][1] and cost[1][j][1]!=cost[2][k][1] and cost[2][k][1]!=cost[0][i][1]:
                    res=min(res,cost[0][i][0]+cost[1][j][0]+cost[2][k][0])
    print(res)


Measured memory_bytes: 5244
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        try (Scanner scanner = new Scanner(System.in)) {
            int a, b;
            while ((a = scanner.nextInt()) != 0 && (b = scanner.nextInt()) != 0) {
                for (int i = 0; i < a; i++) {
                    for (int j = 0; j < b; j++) {
                        System.out.print("#");
                    }
                    System.out.println();
                }
                System.out.println();
            }
        }
    }
}

Measured memory_bytes: 35816
n = int(input())
s = input()

a = ["0","1","2","3","4","5","6","7","8","9"]

c = 0

for i in a:
	for j in a:
		for k in a:
			d = s.find(i)
			if d == -1:
				continue
			e = s[d+1:].find(j)
			if e == -1:
				continue
			e += d+1
			f = s[e+1:].find(k)
			if f == -1:
				continue
			c += 1
print (c)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1e5+5;
int a[N],b[N];
int main() {
    //freopen("in.txt","r",stdin);
    int n,m,q,mi=1e9,ans=1e9;
    scanf("%d%d%d",&n,&m,&q);
    for(int i=1;i<=n;i++) {
        scanf("%d",&a[i]);
        mi=min(mi,a[i]);
    }
    for(int i=1;i<=m;i++) {
        scanf("%d",&b[i]);
        ans=min(ans,mi+b[i]);
    }
    for(int i=0,x,y,c;i<q;i++) {
        scanf("%d%d%d",&x,&y,&c);
        ans=min(ans,a[x]+b[y]-c);
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl "\n"

const int timeLimit = 1980;

i64 xor128()
{
  static i64 x = 123456789, y = 362436069, z = 521288629, w = 88675123;
  i64 t = (x ^ (x << 11));
  x = y;
  y = z;
  z = w;
  return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

i64 D;
i64 c[26];
i64 s[365][26];
vector<i64> ans;

i64 eval(vector<i64> &ans)
{
  i64 score = 0;
  i64 last[26] = {};
  for (i64 i = 0; i < D; i++)
  {
    score += s[i][ans[i]];
    last[ans[i]] = i + 1;
    for (i64 j = 0; j < 26; j++)
      score -= c[j] * (i + 1 - last[j]);
  }
  return score;
}

void solve()
{
  chrono::system_clock::time_point start = chrono::system_clock::now();
  i64 bestScore = -1e18, nowScore = -1e18, loop = 0;
  double C = timeLimit * 100, forceLine;
  i64 currentTime;
  vector<i64> now = ans;
  while ((currentTime = chrono::duration_cast<chrono::microseconds>(chrono::system_clock::now() - start).count() / 1000) < timeLimit)
  {
    i64 t[3] = {xor128() % D, xor128() % 26};
    t[2] = now[t[0]];
    now[t[0]] = t[1];
    i64 score = eval(now);
    forceLine = (timeLimit - currentTime) / C;
    if (bestScore < score)
    {
      ans = now;
      bestScore = score;
    }
    if (nowScore < score || forceLine * 1000 > rand() % 1000)
    {
      nowScore = score;
    }
    else
    {
      now[t[0]] = t[2];
    }
    loop++;
  }
  cerr << "score: " << bestScore + (i64)(1e6) << endl
       << "loop: " << loop << endl;
}

void input()
{
  cin >> D;
  for (i64 i = 0; i < 26; i++)
    cin >> c[i];
  for (i64 i = 0; i < D; i++)
    for (i64 j = 0; j < 26; j++)
      cin >> s[i][j];
  ans.resize(D);
}

void output()
{
  for (i64 i = 0; i < D; i++)
    cout << ans[i] + 1 << endl;
}

int main()
{
  input();
  solve();
  output();
  return 0;
}


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

public class Main {

	public static void main(String[] args) {
		
		String CMD = null ;
		BufferedReader BR = null;
		BR = new BufferedReader(new InputStreamReader(System.in));
		try {
			CMD = BR.readLine();
		} catch (IOException e) {
		
			e.printStackTrace();
		}
		int x = Integer.parseInt(CMD);
		System.out.println(x*x*x);
		
		

	}

}

Measured memory_bytes: 24260
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)

int main(){
  string s,t;
  cin >> s >> t;
  int sn = s.size();
  int tn = t.size();
  vc sc(sn);
  vc tc(tn);
  rep(i,sn){
    sc.at(i) = s.at(i);
  }
  rep(i,tn){
    tc.at(i) = t.at(i);
  }
  sort(sc.begin(),sc.end());
  sort(tc.begin(),tc.end());
  reverse(tc.begin(),tc.end());
  if(sc < tc) cout << "Yes";
  else cout << "No";
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>

#define INF INT_MAX

using namespace std;

vector <int> D;
int n=0;

void initRMQ(int n_){

  n = 1;
  while(n <= n_) n *= 2;
 
  D.resize(2*n-1);

  for(int i=0; i<2*n-1-1; i++) D[i] = INF;
}


void update(int k, int a){

  k += n - 1;
  D[k] = a;

  while(k > 0){
    k = (k-1) / 2;
    D[k] = min(D[k*2+1], D[k*2+2]);
  }
}


int query(int a, int b,int k, int l, int r){

  if(r <=a || b <= l) return INF;
  if(a <= l && r <= b) return D[k];
   
  int vl = query(a, b, k*2+1, l, (l+r)/2);
  int vr = query(a, b, k*2+2,(l+r)/2, r);
  return min(vl, vr);
  
}


int findMin(int a, int b){

  return query(a, b+1, 0, 0, n);
}


int main(){
  int N, L, x;

  cin >> N >> L;

  //  D.resize(N);
  initRMQ(N);


  for(int i=0; i<N; i++){
    cin >> x;
    update(i, x);
  }


  int i = 0;
  while(1){
    cout << findMin(i, i+L-1);
    if(i+L-1 == N-1) break;
    cout << ' ';
    i++;
  }
  cout << endl;
  return 0;
}



Measured memory_bytes: 11028
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main(void) {
    int n,t;
    cin >>n >> t;
    vector<int> c;
    rep(i,n){
        int tmpc,tmpt;
        cin >>tmpc >> tmpt;
        if(tmpt<=t)c.push_back(tmpc); 
    }
    if(c.size()==0){
        cout << "TLE" << endl;
        return 0;
    }
    sort(c.begin(), c.end());
    cout << c[0] << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().run();
	}

	private void run() {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		Node[] T = new Node[n];

		for (int i = 0; i < n; i++) {
			T[i] = new Node();
		}
		int l = 0;
		for (int i = 0; i < n; i++) {
			int v = scanner.nextInt();
			T[v].id = v;
			int d = scanner.nextInt();
			for (int j = 0; j < d; j++) {
				int c = scanner.nextInt();

				if (j == 0) {
					T[v].l = c;
				} else {
					T[l].r = c;
				}
				l = c;
				T[c].p = v;
			}
		}
		int r = -1;
		for (int i = 0; i < n; i++) {
			if (T[i].p == -1) {
				r = i;
				break;
			}
		}
		int[] D = new int[n];
		rec(r, 0, D, T);
		for (int i = 0; i < n; i++) {
			print(i, T, D);
		}
	}

	private void print(int u, Node[] T, int[] D) {
		System.out
				.printf("node %d: parent = %d, depth = %d, ", u, T[u].p, D[u]);
		if (T[u].p == -1)
			System.out.print("root, ");
		else if (T[u].l == -1)
			System.out.print("leaf, ");
		else
			System.out.print("internal node, ");
		System.out.print("[");
		for (int i = 0, c = T[u].l; c != -1; i++, c = T[c].r) {
			if (i != 0)
				System.out.print(", ");
			System.out.print(c);
		}
		System.out.println("]");
	}

	private void rec(int u, int p, int[] D, Node[] T) {
		Deque<Node> deque = new ArrayDeque<Node>();
		deque.offer(T[u]);
		while (!deque.isEmpty()) {
			int t = deque.size();
			for (int i = 0; i < t; i++) {
				Node node = deque.poll();
				D[node.id] = p;
				if (node.l != -1) {
					node = T[node.l];
					while (true) {
						deque.offer(T[node.id]);
						if (node.r != -1) {
							node = T[node.r];
						} else {
							break;
						}
					}
				}
			}
			p++;
		}
	}

	private void slove(Deque<Node> deque, Node node, Node[] T) {
		if (node.r != -1) {
			deque.offer(T[node.r]);
			slove(deque, T[node.r], T);

		}
	}

	class Node {
		int id = -1;
		int p = -1;
		int l = -1;
		int r = -1;
	}
}

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

void solve() {
  string s;
  cin >> s;
  int x = 0;
  for (char c: s) {
    x += c-'0';
  }
  cout << (x%9?"No":"Yes");
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
#define loop(i,x,z) for (int i=x;i<z;i++)
int A[5];
int main()
{
	loop(i, 0, 5)
	{
		cin >> A[i];
		if (A[i] == 0)
		{
			cout << i + 1;
			return 0;
		}
	}
}

Measured memory_bytes: 3564
#include <functional>
#include <queue>
#include <stdio.h>
#include <utility>
#include <vector>

static const int MAX = 10000;
static const int INFINITY = 1 << 20;
static const int WHITE = 0;
static const int GRAY  = 1;
static const int BLACK = 2;

static int n;
static std::vector<std::pair<int, int> > adj[MAX];

void dijkstra()
{
    std::priority_queue<std::pair<int, int>, std::vector<std::pair<int, int> >, std::greater<std::pair<int, int> > > PQ;
    int color[MAX];
    int d[MAX];

    for (int i = 0; i < n; i++) {
        d[i] = INFINITY;
        color[i] = WHITE;
    }

    d[0] = 0;
    PQ.push(std::make_pair(0, 0));
    color[0] = GRAY;

    while (!PQ.empty()) {
        std::pair<int, int> f = PQ.top();
        PQ.pop();
        int u = f.second;
        color[u] = BLACK;
    
        if (d[u] < f.first)
            continue;

        for (int i = 0; i < adj[u].size(); i++) {
            int v = adj[u][i].first;
            if (color[v] == BLACK)
                continue;
            if (d[v] > d[u] + adj[u][i].second) {
                d[v] = d[u] + adj[u][i].second;
                PQ.push(std::make_pair(d[v], v));
                color[v] = GRAY;
            }
        }
    }

    for (int i = 0; i < n; i++) {
        printf("%d %d\n", i, (d[i] == INFINITY) ? -1 : d[i]);
    }
}

int main()
{
    scanf("%d", &n);
    
    for (int i = 0; i < n; i++) {
        int u, k;
        scanf("%d %d", &u, &k);
        for (int j = 0; j < k; j++) {
            int v, c;
            scanf("%d %d", &v, &c);
            adj[u].push_back(std::make_pair(v, c));
        }
    }
    
    dijkstra();
    return 0;
}


Measured memory_bytes: 7704
s = int(input())

a = [s]

for i in range(1, 1000001):
    now = 0
    if a[i-1] % 2 == 0:
        a.append(a[i-1] // 2)
        now = a[i-1] // 2

    else:
        a.append(a[i-1] * 3 + 1)
        now = a[i-1] * 3 + 1

#    print(a)
    
    if now in a[:i]:
        print(i+1)
        break



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

int main()
{
	int N, M, Q,i,j,k,l,m;
	int L1R1[501][501];
	for (i = 0; i < 501; i++) {
		for (j = 0; j < 501; j++) {
			L1R1[i][j] = 0;
		}
	}
	cin >> N >> M >> Q;
	vector<int>L(M);
	vector<int>R(M);
	vector<int>p(Q);
	vector<int>q(Q);
	
	for (i = 0; i < M; i++) {
		cin >> L[i] >> R[i];
		L1R1[L[i]][R[i]]++;
	}
	for (i = 0; i < Q; i++) {
		cin >> p[i] >> q[i];
	}
	for (i = 0; i < 501; i++) {
		for (j = 1; j < 501; j++) {
			L1R1[i][j] += L1R1[i][j-1];
		}
	}
	for (i = 500; i > 0; i--) {
		for (j = 0; j < 501; j++) {
			L1R1[i-1][j] += L1R1[i][j];
		}
	}
	for (i = 0; i < Q; i++) {
		cout << L1R1[p[i]][q[i]] << endl;
	}


    return 0;
}



Measured memory_bytes: 4224
import sys
from fractions import gcd


def cnt(x):
    a = 0
    while True:
        r = x % 2
        if r == 1:
            break
        else:
            a += 1
            x //= 2
    return a


read = sys.stdin.read
N, M, *a = map(int, read().split())
a = list(set(a))
b = [cnt(i) for i in a]
if len(set(b)) != 1:
    print(0)
    exit()

m = 2 * M

lcm = a[0]
for i in a:
    g = gcd(lcm, i)
    lcm = lcm * i // g
    if lcm > m:
        print(0)
        exit()

lcm //= 2
if M < lcm:
    print(0)
else:
    print((M - lcm) // (lcm * 2) + 1)


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

int n, m, x;
int c[13];
int a[13][13];   //first is book, second is increase in skill

vector<int> subset;

int ans = INT_MAX;


void solve(int y){
    if (y == n){
       int skill[m+1] = {0};
       int cost = 0;

       
       if (subset.empty()){
           return;
       }

       for (int i: subset){
           cost += c[i];
           for (int j = 1; j <= m; j++){
               skill[j] += a[i][j];
           }
       }

       bool allX = true;
       for (int i=1; i<=m; i++){
           if (skill[i] < x){
               allX = false;
               break;
           }
       }

       if (allX){
           if (cost < ans){
               ans = cost;
           }
       }
    }
    else{
        solve(y+1);
        subset.push_back(y+1);
        solve(y+1);
        subset.pop_back();
    }
}

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

    cin >> n >> m >> x;
    for (int i = 1; i<=n; i++){
        cin >> c[i];
        for (int j = 1; j<=m; j++){
            cin >> a[i][j];
        }
    }

    solve(0);

    if (ans == INT_MAX){
        cout << "-1";
    }
    else{
        cout << ans;
    }
}

Measured memory_bytes: 3672
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = (int)3e5;

ll mpow(ll a, ll b){
	if(b==0) return 1;
	else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
	else return mpow(a,b-1) * a % MOD;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
	if(kaijo_memo.size() > n) return kaijo_memo[n];
	if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
	while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
	return kaijo_memo[n];
}
ll nCr(ll n, ll r){
	if(n < r || r < 0) return 0;
	ll ret = 1;
	ret *= kaijo(n); ret %= MOD;
	ret *= mpow(kaijo(r), MOD-2); ret %= MOD;
	ret *= mpow(kaijo(n-r), MOD-2); ret %= MOD;
	return ret;
}



int main(void){
	ll h,w;
	cin>>h>>w;
	ll ans = LINF;
	rep(hoge,2){
		reps(i,h-1){
			ll s1 = (h-i) * w;
			ll s2 = i/2 * w;
			ll s3 = (i+1)/2 * w;
			ll min_s = min(s1,min(s2,s3));
			ll max_s = max(s1,max(s2,s3));
			ans = min(ans, max_s - min_s);

			s2 = i * (w/2);
			s3 = i * ((w+1)/2);
			min_s = min(s1,min(s2,s3));
			max_s = max(s1,max(s2,s3));
			ans = min(ans, max_s - min_s);
		}
		ll tmp = h; h = w; w = tmp;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
from itertools import accumulate

def mi():
    return map(int, input().split())

def main():
    N, K = mi()
    A = list(mi())

    for _ in range(K):
        l = [0]*N
        for i in range(N):
            left = max(i-A[i], 0)
            right = min(i+A[i]+1, N)
            l[left] += 1
            if right < N:
                l[right] -= 1
        if A != list(accumulate(l)):
            A = list(accumulate(l))
        else:
            break
    print(' '.join(list(map(str, A))))

if __name__ == '__main__':
    main()

Measured memory_bytes: 182768
import java.util.*;

class Main {
    public static void main(String[] args) {
        new Solver().run();
    }
}

class Solver {

    public void run() {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();

        int v = A % 10;
        if (v == 3) {
            System.out.println("bon");
        } else if (
                v == 0 ||
                v == 1 ||
                v == 6 ||
                v == 8)
            System.out.println("pon");
        else 
            System.out.println("hon");


        return;
    }

}

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

using ll = long long;

constexpr ll inf = 1e18;

ll dp[5001][5001][2];
ll ndp[5001][2];

int main() {
    for(int i = 0; i < 5001; ++i) {
        for(int j = 0; j < 5001; ++j) {
            for(int k = 0; k < 2; ++k) {
                dp[i][j][k] = inf;
            }
        }
    }

    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    vector<vector<int>> g(n);
    for(int i = 0; i < n - 1; ++i) {
        int u, v; cin >> u >> v;
        g[u - 1].push_back(v - 1);
        g[v - 1].push_back(u - 1);
    }

    // 1 => including computer
    vector<int> sz(n);
    function<void(int, int)> solve = [&] (int v, int p) {
        sz[v] = 1;
        for(auto to : g[v]) {
            if(to == p) continue;
            solve(to, v);
            sz[v] += sz[to];
        }
        dp[v][0][a[v] < 0] = a[v];
        int cur_sz = 1;
        for(auto to : g[v]) {
            if(to == p) continue;
            for(int i = 0; i <= n; ++i) {
                for(int j = 0; j < 2; ++j) {
                    ndp[i][j] = inf;
                }
            }
            for(int i = 0; i <= cur_sz - 1; ++i) {
                for(int c1 = 0; c1 < 2; ++c1) {
                if(dp[v][i][c1] == inf) continue;
                    for(int j = 0; j <= sz[to] - 1; ++j) {
                        for(int c2 = 0; c2 < 2; ++c2) {
                            if(dp[to][j][c2] == inf) continue;
                            // connect
                            if(i + j == 0) {
                                ndp[i + j][max(c1, c2)] = dp[v][i][c1] + dp[to][j][c2];
                            } else {
                                ndp[i + j][max(c1, c2)] = min(ndp[i + j][max(c1, c2)], dp[v][i][c1] + dp[to][j][c2]);
                            }
                            // cut
                            if(c2 == 0 || dp[to][j][c2] < 0) {
                                ndp[i + j + 1][c1] = min(ndp[i + j + 1][c1], dp[v][i][c1]);
                            }
                        }
                    }
                }
            }
            memcpy(dp[v], ndp, sizeof(ndp));
            cur_sz += sz[to];
        }
    };
    solve(0, -1);

    int ans = n;
    for(int i = 0; i < n; ++i) {
        if(dp[0][i][0] != inf || dp[0][i][1] < 0) {
            ans = i;
            break;
        }
    }

    cout << ans << endl;
}

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

string del(string S) {
    if (S.size() == 0) {
        return S;
    } else {
        string S_new;
        for (int i = 0; i < S.size() - 1; i++) {
            S_new += S[i];
        }
        return S_new;
    }
}

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

string ans;
for (int i = 0; i < s.size(); i++) {
    if (s[i] == '0') {
        ans += '0';
    } else if (s[i] == '1') {  
        ans += '1';
    } else if (s[i] == 'B') {
        ans = del(ans);
    }
}
cout << ans << endl; 
}


Measured memory_bytes: 256
#include<stdio.h>
int N, L[111];
int main(){
	scanf("%d", &N);
	for(int i=0; i<N; i++)scanf("%d", L+i);
	int ans = 0;
	for(int i=0; i<N; i++){
		for(int j=i+1; j<N; j++){
			for(int k=j+1; k<N; k++){
				if(L[i]==L[j] || L[j]==L[k] || L[k]==L[i])continue;
				if(L[i]<L[j]+L[k] && L[j]<L[k]+L[i] && L[k]<L[i]+L[j])ans++;
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1732
#include <stdio.h>
int main() {int i,j,k,A=0,B=0;while (scanf("%d,%d,%d",&i,&j,&k)!=EOF) {if (k*k==i*i+j*j) A++; else if (i==j) B++;} printf("%d\n%d\n",A,B);return 0;}

Measured memory_bytes: 1024
import sys

n = int(sys.stdin.readline().rstrip())
s = sys.stdin.readline().rstrip()

def main():
    l = r = 0
    for char in s:
        if char == '(':
            r += 1
        elif char == ')':
            if r:
                r -= 1
            else:
                l += 1

    return '(' * l + s + ')' * r

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 3060
import copy

def j(n):
    if n:print("Yes")
    else:print("No")
    exit(0)
rem = 10 ** 9 + 7

"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def iprow():
    return [int(i) for i in input().split()]
def ips():
    return (int(i) for i in input().split())
def printrow(a):
    for i in a:
        print(i)
s = 0
n,r =ips()
a = iprow()
other=0
for i in range(n):
    for k in range(n):
        if a[i]>a[k] and i<k:
            s+=1
        elif i>k and a[i]>a[k]:
            other+=1
adder = 0
rate = s
ans = 0
ans =((s + (s * r)) * r)//2 + ((other + other*(r-1)) * (r-1))//2
print(ans%rem)


Measured memory_bytes: 3656
import java.util.Scanner;

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

		if(a==b) System.out.println("Draw");
		else {
			if(a==1 || b==2) System.out.println("Alice");
			else if(a==2 || b==1) System.out.println("Bob");
			else if(a>b) System.out.println("Alice");
			else if(a<b) System.out.println("Bob");
		}
	}
	
} 

Measured memory_bytes: 21712
/*
    Author:zeke

    pass System Test!
    GET AC!!
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
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 pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 998244353;
ll INF = 1e18;
// cout << "Case #" << index << " :IMPOSSIBLE";
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    ll n,s;
    cin>>n>>s;
    V vec(n);
    rep(i,n)cin>>vec[i];
    VV dp(n+1,V(s+1));
    //S&T
    //T not S
    //not T&S
    dp[0][0]=1;
    rep(i,n){
        rep(j,s+1){
            dp[i+1][j]+=2*dp[i][j];
            dp[i+1][j]%=MOD;
            if(j+vec[i]<=s){
                dp[i+1][j+vec[i]]+=dp[i][j];
                dp[i + 1][j + vec[i]] %= MOD;
            }
        }
    }
    cout<<dp[n][s]<<endl;
}


Measured memory_bytes: 73692
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
  long long int d;
  for(;cin>>d,d;)
    {
      int n,m;
      cin>>n>>m;
      vector<long long int> dd;
      for(int i=0;i<n-1;i++)
	{
	  long long int tmp;
	  cin>>tmp;
	  dd.push_back(tmp);
	}
      sort(dd.begin(),dd.end());

      long long int ans=0;
      for(int i=0;i<m;i++)
	{
	  long long int k;
	  cin>>k;
	  long long int tmp=k;
	  tmp=min(tmp,d-k);
	  vector<long long int>::iterator it = lower_bound(dd.begin(),dd.end(),k);
	  //	  cout<<"begin:"<<*(dd.begin())<<endl;
	  //	  cout<<"end:"<<*(dd.end())<<endl;
	  if(it!=dd.end())
	    {
	      tmp=min(tmp,*(it)-k);
	    }
	  if(it!=dd.begin())
	    {
	      it--;
	      tmp=min(tmp,k-*(it));
	    }
	  //cout<<"add:"<<tmp<<endl;
	  ans+=tmp;
	}
	  cout<<ans<<endl;
    }

}

Measured memory_bytes: 2128
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
 
int main() {
    ll n;
    cin>>n;
    vector<ll> A;
    while(n>0)
    {
        n--;
        ll k=(n)%26;
        n/=26;
        A.push_back(k);
    }
    reverse(A.begin(), A.end());
    for(ll j : A)
    {
        cout<<char(97 + j);
    }
    return 0;
}

Measured memory_bytes: 3628