akhauriyash/Code-Regression huggingface dataset:
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//等価なものに変換する思考
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//配列はvector<>を使う：意味わからないエラーがなくなる。
//背反な事象にちゃんとわける
//チェックリストはマップを使う
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
//またはかかつか
//例外処理は最初にする
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

//円周率
const double PI = 3.14159265358979323846;
//割るやつ
const ll M = (pow(10, 9) + 7);

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

//階乗計算
ll f(ll n) {
	if (n == 0 || n == 1) return 1;
	else return (n * f(n - 1)) % M;
}

int main() {
	string a, b, c; cin >> a >> b >> c;
	ll cnta = 0, cntb = 0, cntc = 0;

	int t = 0;
	while (1) {
		if (t == 0) {
			if (a[cnta] == 'a') t = 0;
			if (a[cnta] == 'b') t = 1;
			if (a[cnta] == 'c') t = 2;
			cnta++;
		}
		if (t == 1) {
			if (b[cntb] == 'a') t = 0;
			if (b[cntb] == 'b') t = 1;
			if (a[cntb] == 'c') t = 2;
			cntb++;
		}
		if (t == 2) {
			if (c[cntc] == 'a') t = 0;
			if (c[cntc] == 'b') t = 1;
			if (c[cntc] == 'c') t = 2;
			cntc++;
		}

		if (t == 0 && cnta == a.size()+1) {
			cout << 'A' << endl;
			return 0;
		}
		if (t == 1 && cntb == b.size()+1) {
			cout << 'B' << endl;
			return 0;
		}
		if (t == 2 && cntc == c.size()+1) {
			cout << 'C' << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF 1e9+7
#define LLINF 1e30
// #define int ll
using namespace std;
const int MOD = 1e9 +7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,c,d[40][40]={},t[4][40]={},ans=1<<30;
    cin>>n>>c;
    rep(i,c){
        rep(j,c) cin>>d[i][j];
    }
    rep(i,n){
        rep(j,n){
            int x;
            cin>>x;
            t[(i+j)%3][x-1]++;
        }
    }
    rep(i,c){
        rep(j,c){
            if(i !=j){
                rep(k,c){
                    if(i !=k && j != k){
                        int tt=0;
                        rep(l,c) tt += d[l][i]*t[0][l];
                        rep(l,c) tt += d[l][j]*t[1][l];
                        rep(l,c) tt += d[l][k]*t[2][l];
                        if(tt<ans) ans=tt;
                    }
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

        int p = sc.nextInt();
        int q = sc.nextInt();
        int r = sc.nextInt();

        //        for (int i = 0; i < n; i++) {
        //
        //        }

        sc.close();

        int ans = Math.min(p + q, Math.min(q + r, p + r));

        System.out.println(ans);

    }

}

Measured memory_bytes: 22100
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

fn main() {
    input! {
        n: usize,
        k: usize,
    }
    let mut f = std::collections::BTreeSet::new();
    for _ in 0..k {
        input! {
            d: usize,
            a: [Usize1; d],
        }
        for a in a {
            f.insert(a);
        }
    }
    println!("{}", n - f.len());
}


Measured memory_bytes: 2156
#include<bits/stdc++.h>
using namespace std;
#define ran 111111
int n;
int a[ran],b[ran];

int N;
int A[ran],B[ran];

int n2;
map<int,int> Map;
int h(int x){
	if(Map.count(x))
		return Map[x];
	Map[x] = n2;
	n2++;
	return Map[x];
}

vector<pair<int,int> > e;
int ace[ran];
int ancestor(int x){return x-ace[x]?ace[x]=ancestor(ace[x]):x;}
int stat(){
	for(int i=0; i<n2; i++)
		ace[i] = i;
	for(vector<pair<int,int> >::iterator it = e.begin(); it!=e.end(); it++)
		ace[ancestor(it->first)]=ancestor(it->second);
	int res = 0;
	for(int i=0; i<n2; i++)
		if(ancestor(i)==i)
			res++;
	return res;
}

int main(){
	scanf("%d",&n);
	for(int i=0; i<n; i++){
		scanf("%d",&a[i]);
		a[n] ^= a[i];
	}
	for(int i=0; i<n; i++){
		scanf("%d",&b[i]);
		b[n] ^= b[i];
	}

	N = n+1;
	for(int i=0; i<N; i++){
		A[i] = a[i];
		B[i] = b[i];
	}
	sort(A, A+N);
	sort(B, B+N);
	bool flag = true;
	for(int i=0; i<N; i++)
		if(A[i] != B[i])
			flag = false;
	if(!flag){
		puts("-1");
		return 0;
	}

	for(int i=0; i<N; i++)
		if(a[i] != b[i]){
			int t1 = h(a[i]);
			int t2 = h(b[i]);
			e.push_back(make_pair(t1,t2));
		}

	int res = e.size();

	if(a[N-1] != b[N-1]){
		res += stat() - 2;
	}else{
		res += stat();
		if(Map.count(a[N-1]))
			res --;
	}
	printf("%d\n",res);
	return 0;
}


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

public class Main{
  public static void main(String[] args) throws Exception{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(br.readLine());
    String[] s = br.readLine().split(" ");
    int[] a = new int[10];
    for(int i = 0; i < n; i++){
      a[i] = Integer.parseInt(s[i]);
    }
    
    int max = 0;
    int sum = 0;
    for(int i = 0; i < n; i++){
      sum += a[i];
      max = Math.max(max, a[i]);
    }
    
    if(max < sum - max) System.out.println("Yes");
    else System.out.println("No");
  }
}
    

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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int ans = 0;
            for (int i = 0; i < s.Length; i++)
            {
                if (s[i] == '+')
                {
                    ans++;
                }
                else
                {
                    ans--;
                }
            }
            Console.WriteLine(ans);
            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
/*
	Karya anak bangsa yang paling agung
	Author : Yohandi or... bukan..
*/

#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define endl "\n"
#define INF 4e18

#define all(a) a.begin(),a.end()
#define lb(a,x) (lower_bound(all(a),x)-a.begin())
#define ub(a,x) (upper_bound(all(a),x)-a.begin())

#define rep(a,x,y) for(int a=(int)x;a<=(int)y;++a)
#define repd(a,x,y,d) for(int a=(int)x;a<=(int)y;a+=d)
#define res(a,x,y) for(int a=(int)x;a>=(int)y;--a)
#define resd(a,x,y,d) for(int a=(int)x;a>=(int)y;a-=d)

// Ordered Set, Ordered Multiset
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define o_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
#define o_multiset tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>
using namespace __gnu_pbds;
// .order_of_key(x) -> Number of elements less than x
// * .find_by_order(k) -> Kth smallest element (0-based)
// .erase(x) -> Remove all elements equal to x

#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
using lint=long long;

mt19937 rng(time(NULL));

lint Power(lint A,lint B,lint C){
	if(!B) return 1LL;
	lint tmp=Power(A,B>>1,C);
	return tmp*tmp%C*(B&1?A:1)%C;
}

lint N,Source,Sink,X;
lint Cost[105],Par[105];
lint Cap[105][105],Adj[105][105];
bool Vis[105];

bool BFS(){
    lint U,V;
    memset(Vis,0,sizeof(Vis));
    queue<int> Q;
    Q.push(Source);
    Vis[Source]=1;
    Par[Source]=-1;
    while(!Q.empty()){
        U=Q.front();
        Q.pop();
        for(V=0;V<=N+1;++V){
            if(Vis[V]==0&&Cap[U][V]>0){
                Q.push(V);
                Par[V]=U;
                Vis[V]=1;
            }
        }
    }
    return Vis[Sink];
}

lint Maxflow(){
    lint U,V;
    for(int i=0;i<=N+1;++i)
        for(int j=0;j<=N+1;++j)
            Cap[i][j]=Adj[i][j];
    lint Max_Flow=0;
    while(BFS()){
        lint Path_Flow=INF;
        V=Sink;
        while(V!=Source){
            U=Par[V];
            Path_Flow=min(Path_Flow,Cap[U][V]);
            V=Par[V];
        }
        V=Sink;
        while(V!=Source){
            U=Par[V];
            Cap[U][V]-=Path_Flow;
            Cap[V][U]+=Path_Flow;
            V=Par[V];
        }
        Max_Flow+=Path_Flow;
    }
    return Max_Flow;
}

int main(){
//	ios_base::sync_with_stdio(0);
//	cin.tie(0); cout.tie(0);
    cin>>N;
    for(int i=1;i<=N;++i){
        cin>>Cost[i];
        if(Cost[i]>0){
            X+=Cost[i];
            Adj[i][N+1]=Cost[i];
        } else {
            Adj[0][i]=-Cost[i];
        }
        for(int j=2*i;j<=N;j+=i){
            Adj[i][j]=INF;
        }
    }
    Source=0;
    Sink=N+1;
    cout<<X-Maxflow()<<endl;
	return 0;
}




Measured memory_bytes: 384
import java.util.*;

public class Main {
    public void main(Scanner sc) {
        String s = sc.next();
        int length = s.length();

        int cnt = 0;
        int l = 0;
        int r = length - 1;
        while (l <= r) {
            char cl = s.charAt(l);
            char cr = s.charAt(r);

            if (cl == cr) {
                l++;
                r--;
            } else {
                if (cl == 'x') {
                    cnt++;
                    l++;
                } else if (cr == 'x') {
                    cnt++;
                    r--;
                } else {
                    cnt = -1;
                    break;
                }
            }
        }

        System.out.println(cnt);
    }

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


Measured memory_bytes: 26748
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>

typedef long long ll;

using namespace std;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}
int main() {
    int N; cin >> N;
    int v[N]; for (int i = 0; i < N; ++i) cin >> v[i];
    int c[N]; for (int i = 0; i < N; ++i) cin >> c[i];
    int res = 0;
    for (int i = 0; i < N; ++i) {
        if (v[i] > c[i]) res += v[i] - c[i];
    }
    cout << res << endl;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
S = input()

s1 = S[0:K-1]
c = S[K-1]
s2 = S[K:]

if c == "A":
    c = "a"
elif c == "B":
    c = "b"
else:
    c = "c"

ans = s1 + c + s2
print(ans)

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

int main(){
    int n, x;
    cin >> n >> x;
    ll l[n];
    rep(i, n) cin >> l[i];
    ll now = 0, cnt = 0;
    int i = 0;
    while(now <= x && i <= n){
        cnt ++;
        now += l[i];
        i++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <climits>

using namespace std;


int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);

	int x, t;
	cin >> x >> t;
	cout << max(0, x - t) << endl;

	return 0;
}

Measured memory_bytes: 256
A, B, C, D = list(map(int,input().split()))
A = A - 1

def gcd(c, d):
    c, d= max(c, d), min(c, d)
    if c % d == 0:
        return d
    else :
        while c % d != 0:
            c, d = d, c % d
        return d

L = C * D // gcd(C, D)

ans = B - A - ( B // C - A // C + B // D - A // D - B // L + A // L)
print(ans)

Measured memory_bytes: 3064
n, m  = map(int,input().split())
a = [int(input()) for _ in range(m)]

MOD = 10**9+7

dp = [0]*(n+1)
ng = [False]*(n+1)
for i in a:
    ng[i] = True
    
dp[0] = 1
if not ng[1]:
    dp[1] = 1
for i in range(2, n+1):
    if ng[i]:
        continue
    else:
        dp[i] = (dp[i-1] + dp[i-2]) % MOD
print(dp[n])

Measured memory_bytes: 81092
X, N = [int(i) for i in input().split()]
P = [int(i) for i in input().split()]
# Xは0~101の値になる
result = 0
current = 102
for i in range(102):
    if i not in P:
        if abs(X - i) < current:
            result = i
            current = abs(X - i)
print(result)

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

public class Main { 
	public static void main(String args[]) throws IOException{
		Scanner scr = new Scanner(System.in);
		while (true){
		    try{
				String[] str = scr.nextLine().split(" ", 0);
				int n = Integer.parseInt(str[0]);
				int x = Integer.parseInt(str[1]);
				if (n==0 && x==0) break; //??\?????????
				System.out.println( SearchTrio(n, x) );
			}catch(Exception e){
				System.err.println("Exception");
				break;
			}
        }
		/*String[] str = scr.nextLine().split(" ", 0);
		System.out.println( SearchPair(Integer.parseInt(str[0]),
				Integer.parseInt(str[1]), Integer.parseInt(str[2])) );*/
		scr.close();
	}
	
	
	private static int SearchTrio(int n, int x){
		int r=0;
	    for(int i=1; i<(x/3); i++){
	    	r += SearchPair(i+1, n, x-i);
		}
	    return r;
	}
	
	// min??\???max??\??????2??°????????§x???????????????
	private static int SearchPair(int min, int max, int x){
		if( min+max <= x) return Math.max((max - x/2), 0);
		else return Math.max((CeilDiv(x,2) - min),0);
	}
	private static int CeilDiv(int divided, int divider){
		if(divided%2==0) return divided/divider;
		else return divided/divider+1;
	}
}

Measured memory_bytes: 25992
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int t[] = new int[n + 1];
		int x[] = new int[n + 1];
		int y[] = new int[n + 1];
		boolean able = true;
		for (int i = 1; i <= n; i++) {
			t[i] = sc.nextInt();
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
		}
		for (int i = 0; i < n; i++) {
			int tt = t[i + 1] - t[i];
			int xt = (x[i + 1] >= x[i])? x[i + 1] - x[i] : x[i] - x[i + 1];
			int yt = (y[i + 1] >= y[i])? y[i + 1] - y[i] : y[i] - y[i + 1];
			if (xt + yt > tt || (xt + yt) % 2 != tt % 2) {
				able = false;
				break;
			}
		}
		System.out.println((able)? "Yes" : "No");
	}
}

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

int main(){
	int H, W;
	cin >> H >> W;
	char a[H+1][W+1];
	bool complete;
	bool cmpH[H+1];
	bool cmpW[W+1];
	for(int i = 1; i <= H; i++) for(int j = 1; j <= W; j++){
		cin >> a[i][j];
	}
	for(int i = 1; i <= H; i++){
		complete = true;
		for(int j = 1; j <= W; j++){
			if(a[i][j] == '#'){
				complete = false;
				break;
			}
		}
		if(complete) cmpH[i] = true;
		else cmpH[i] = false;
	}
	for(int j = 1; j <= W; j++){
		complete = true;
		for(int i = 1; i <= H; i++){
			if(a[i][j] == '#'){
				complete = false;
				break;
			}
		}
		if(complete) cmpW[j] = true;
		else cmpW[j] = false;
	}	
	for(int i = 1; i <= H; i++){
		if(cmpH[i]) continue;
		for(int j = 1; j <= W; j++){
			if(cmpW[j]) continue;
			cout << a[i][j];
		}
		cout << endl;
	}
}


Measured memory_bytes: 256
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
p = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    r = ni()

    print(2 * math.pi * r)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9740
#include "bits/stdc++.h"
#include<random>
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
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<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7, INF = 1e16;

lint N, x;
int main() {
	cin >> N >> x;
	if (x == 1 || x == 2 * N - 1) {
		cout << "No" << endl;
	}
	else if(N == 2 && x == 2) {
		cout << "Yes" << endl;
		cout << 1 << endl;
		cout << 2 << endl;
		cout << 3 << endl;
	}
	else {
		cout << "Yes" << endl;
		vector<lint> vec;
		REP(i, 2 * N - 1) {
			vec.push_back(i + 1);
		}
		if (x != 2 * N - 2) {
			swap(vec[N - 1], vec[x - 1]);
			swap(vec[N], vec[x - 2]);
			swap(vec[N - 2], vec[2 * N - 3]);
			swap(vec[N + 1], vec[2 * N - 2]);
		}
		else {
			swap(vec[N - 1], vec[x - 1]);
			swap(vec[N], vec[x]);
			swap(vec[N - 2], vec[0]);
			swap(vec[N + 1], vec[1]);
		}
		REP(i, 2 * N - 1) {
			cout << vec[i] << endl;
		}
	}
}


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

void solve(long long N, long long X, long long T)
{

    ll ans;
    if (N % X == 0)
        ans = N / X * T;

    else
    {
        ans = (N / X + 1) * T;
    }
    cout << ans << endl;
}

signed main()
{
    long long N;
    scanf("%lld", &N);
    long long X;
    scanf("%lld", &X);
    long long T;
    scanf("%lld", &T);
    solve(N, X, T);
    return 0;
}


Measured memory_bytes: 3664
// Seek Knowledge from the cradle to the grave
// Author : Syed Mujtaba Hadi Jafri
#include <bits/stdc++.h>
using namespace std;
#define int long long
int n, t[1000000];
void build(int a[], int v, int tl, int tr) {
    if (tl == tr) {
        t[v] = a[tl];
    } else {
        int tm = (tl + tr) / 2;
        build(a, v*2, tl, tm);
        build(a, v*2+1, tm+1, tr);
        t[v]  = max(t[v*2] ,t[v*2+1]);
        
    }
}
int sum(int v, int tl, int tr, int l, int r) {
    if (l > r) 
        return 0;
    if (l == tl && r == tr)
    {
        return t[v];
    }
    int tm = (tl + tr) / 2;
    return max(sum(v*2, tl, tm, l, min(r, tm))
           , sum(v*2+1, tm+1, tr, max(l, tm+1), r));
}
void update(int v, int tl, int tr, int pos, int new_val) {
    if (tl == tr) {
        t[v] = new_val;
    } else {
        int tm = (tl + tr) / 2;
        if (pos <= tm)
            update(v*2, tl, tm, pos, new_val);
        else
            update(v*2+1, tm+1, tr, pos, new_val);
        t[v] = max(t[v*2], t[v*2+1]);
    }
}
signed main()
{
	cin >> n;
	int h[n], a[n];
	for(int i = 0; i < n; i++)
		cin >> h[i];
	for(int i = 0; i < n; i++)
		cin >> a[i];
	int LIS[200005] = {0};
	build(LIS, 1, 0, 200004);
	int ans = -1;
	for(int i = 0; i < n; i++)
	{	
		LIS[h[i]] = max(LIS[h[i]], a[i] + sum(1, 0, 200004, 0, h[i] - 1));
		update(1, 0, 200004, h[i], LIS[h[i]]);	
		ans = max(ans, LIS[h[i]]);
	}
	cout << ans << endl;
}

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

using namespace std;

#define TEMP_T template<typename T>
TEMP_T void sort(T& v){ sort(v.begin(), v.end()); }
TEMP_T void revs(T& v){ reverse(v.begin(), v.end()); }
TEMP_T void uniq(T& v){ sort(v); v.erase(unique(v.begin(), v.end()), v.end()); }
TEMP_T T    cums(T& v){ T r(v.size()); partial_sum(v.begin(), v.end(), r.begin()); return r; }
TEMP_T void show(T& v, char delim=' ', char end='\n'){ for(int i=0; i<v.size()-1; i++) cout << v[i] << delim; cout << v[v.size()-1] << end; }
TEMP_T T    acum(vector<T>& v, T b=0){ return accumulate(v.begin(), v.end(), b); }
TEMP_T vector<T> inpt(int n){ vector<T> v(n); for (int i=0; i<n; i++) cin >> v[i]; return v; }

static inline int in(){ int x; scanf("%d", &x); return x; }
static const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
static const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};

struct Field {
  Field(int w, int h) : w(w), h(h) {}
  bool invalid(int x, int y){ return x < 0 || w <= x || y < 0 || h <= y; }
  const int w, h;
};

struct Solver {
  Solver(){}
  int input(){
    string line;
    getline(cin, line);
    if (line == "0") return 1;
    stringstream ss(line);
    string token;
    while (getline(ss, token, ' ')){
      stringstream is(token);
      int c;
      is >> c;
      card.push_back(c);
    }
    return 0;
  }
  int solve(){
    sort(card);
    int one_cnt = 0;
    int score = 0;
    for (int i = 0; i < card.size(); i++){
      if (card[i] == 1){
        one_cnt++;
        score += 11;
      }
      else {
        score += min(card[i], 10);
      }
      while (score > 21){
        if (one_cnt){
          score -= 10;
          one_cnt--;
        }
        else return 0;
      }
    }
    return score;
  }
  vector<int> card;
};

int main()
{
  while (1){
    Solver s;
    if (s.input()) break;
    cout << s.solve() << endl;
  }

  return (0);
}

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

int main(){
  string A,B;
  int count=0;
  cin >> B;
  A = "CODEFESTIVAL2016";
  for(int i=0;i<16;i++){
    if(A.at(i) != B.at(i)){
      count ++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		String[] ss = s.split(" ");
		int a = Integer.parseInt(ss[0]);
		int b = Integer.parseInt(ss[1]);

		System.out.print(a * b);
		System.out.print(" ");
		System.out.println((a + b) * 2);
	}

}

Measured memory_bytes: 25988
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#pragma region Macros
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define all(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
int gcd(int a, int b) // assuming a,b >= 1
{
    if (a < b)
        swap(a, b);
    if (b == 0)
        return a;
    if (a % b == 0)
        return b;
    return gcd(b, a % b);
}
int lcm(int a, int b) // assuming a,b >= 1
{
    return  a * b / gcd(a, b);
}
using namespace std;
#pragma endregion
signed main() {
    int N,K;
    string S;
    cin >> N >> K >> S;
    S[K - 1] = S[K-1]+32;
    cout << S;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m;
char s[105];
int cnt[100];
int main()
{
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        cin>>s;
        for(int j=0;j<m;j++)
        {
            cnt[s[j]-'a'+1]++;
        }
    }
    if(n%2==0&&m%2==0)
    {
        for(int j=1;j<=26;j++)
        {
            if(cnt[j]%4!=0)
            {
                puts("No");
                return 0;
            }
        }
        puts("Yes");
        return 0;
    }
    else if(n%2==1&&m%2==1)
    {
        int tmp=0,tt=0;
        for(int i=1;i<=26;i++)
        {
            if(cnt[i]%2==1)tt++;
            tmp+=cnt[i]/4;
        }
        if(tt>1||tmp<(n-1)*(m-1)/4)puts("No");
        else puts("Yes");
    }
    else
    {
        if(n%2==0)swap(n,m);
        int tmp=0;
        for(int i=1;i<=26;i++)
        {
            if(cnt[i]%2==1)
            {
                puts("No");
                return 0;
            }
            else tmp+=cnt[i]/4;
        }
        if(tmp<(n-1)*m/4)puts("No");
        else puts("Yes");
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int   //used int to avoid mle
#define ulli unsigned long long int 
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(lli i=a;i<b;i++)
#define initialize(array,size,value) for(lli i=0;i<size;i++) array[i]=value
#define couta(array,size) for(lli i=0;i<size;i++) cout<<array[i]<<" "
#define vl vector<lli>
#define vp vector< pair <lli,lli> >
#define sl set<lli>
#define spl set<pll>
#define msl multiset <lli>
#define msp multiset <pll>
#define pll pair<lli, lli>
#define mll map<lli, lli>              //for( map<lli, lli>::iterator i=temp.begin();i!=temp.end();i++)cout<<i->fi<<" "<<i->se<<endl;
#define mvl map<lli, vl>
#define umll unordered_map<lli, lli>
#define vt vector<pair<lli, pll >  >
#define vf vector<pair<pll,pll > >
#define qu queue<lli>
#define pq priority_queue<lli>
#define dq deque <lli>
#define ptr vector<lli>::iterator
#define bs(array,x) binary_search(array.begin(),array.end(),x)
#define lb(array,x) lower_bound(array.begin(),array.end(),x)
#define ub(array,x) upper_bound(array.begin(),array.end(),x)
#define nobw(array,i,j) upper_bound(array.begin(), array.end(), j)-lower_bound(array.begin(), array.end(), i) //number of numbers between i & j
#define vc clear()
#define endl '\n'
#define sp system("pause");
#define INF 9223372036854775807
#define MINF -9223372036854775808
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
lli mod=1000000007;
//string s=bitset<32>(n).to_string();
int main()
{
 	ios::sync_with_stdio(0);
    cin.tie(0);
   
        lli a,b;
        cin>>a>>b;
        lli g=__gcd(a,b);
        cout<<(a*b)/g;
  
}

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

using namespace std;

int main(){
    int N;
    int sum = 0;
    
    cin >> N;

    vector<int> d(N);

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

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

        for(int j=0;j<N;j++){

            if(i != j){
            sum += d[i]*d[j];
            }

        }

    }

    cout << sum/2 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, h, a[100005] = {}, b[100005] = {}, m = 0, d = 0;
    cin >> n >> h;
    for (int i = 0; i < n; i++) cin >> a[i] >> b[i], m = max(m, a[i]);
    sort(b, b + n);
    for (int i = n - 1; i >= 0; i--) {
        if (b[i] < m) break;
        h -= b[i];
        d++;
        if (h <= 0) {
            cout << d;
            return 0;
        }
    }
    cout << d + (h - 1) / m + 1;
}


Measured memory_bytes: 3952
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;

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

__attribute__ ((constructor))
void init() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(10);
}

signed main(){
  int x;
  cin >> x;
  if(x==0)
    cout << 1 << endl;
  else
    cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 3616
#include<stdio.h>
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <functional>
#include <stdio.h>
#include <array>
#include <algorithm>
#include <string>
#include <string.h>
#include <assert.h>
#include <stdio.h>
#include <queue>
#include<iomanip>
#include<bitset>
#include<stack>
#include<set>
#include<limits>
#include <complex>
#include<cstdlib>
using namespace std;

vector<vector<int>>outs;
int N, M, K;
bool check(const vector<int>&nums) {
	for (int i = 0; i < N-1; ++i) {
		if (outs[nums[i]][nums[i + 1]]) {
			return false;
		}
	}
	if (outs[nums[N - 1]][nums[0]]) {
		return false;
	}
	else {
		return true;
	}
}

int main() {
	while (1) {

		long long int N, M; cin >> N >> M;
		if (!N)break;
		vector<long long int>attacks(11);
		for (int i = 0; i < N; ++i) {
			long long int d, p; cin >> d >> p;
			attacks[p] += d;
		}
		long long int totalattack = 0;
		for (int i = 1; i <= 10; ++i) {
			totalattack += i*attacks[i];
		}
		long long int minusattack = 0;
		int num = 10;
		while (M&&num) {
			int usemoney = min(M, attacks[num]);
			minusattack += num*usemoney;
			M -= usemoney;
			num--;
		}
		cout << totalattack - minusattack << endl;
	
	}
	
	return 0;
}

Measured memory_bytes: 3020
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(){
    int N,A;
    cin>>N>>A;
    bool isPayable=true;

    N=N%500;
    if(N<=A){
        isPayable=true;
    }else{
        isPayable=false;
    }


    if(isPayable){
        puts("Yes");
    }else{
        puts("No");
    }

}

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

#define ll long long
#define ld long double
#define F first
#define S second

#define ONLINE_JUDGE 1

using namespace std;

const int mod = 1e9+7;

void solve(){
	int x,y,a,b,c;
	cin >> x >> y >> a >> b >> c;
	vector<int> p(a);
	vector<int> q(b);
	vector<int> r(c);
	vector<int> t;
	for(int i = 0; i < a; i++){
		cin >> p[i];
	}
	for(int i = 0; i < b; i++){
		cin >> q[i];
	}
	for(int i = 0; i < c; i++){
		cin >> r[i];
		t.push_back(r[i]);
	}
	sort(p.rbegin(), p.rend());
	sort(q.rbegin(), q.rend());
	
	for(int i = 0; i < x; i++){
		t.push_back(p[i]);
	}
	for(int i = 0; i < y; i++){
		t.push_back(q[i]);
	}
	sort(t.rbegin(), t.rend());
	ll res = 0;
	
//	for(int i = 0; i < y + x + c; i++){
//		cout << t[i] << " ";
//	}
//	cout << "\n";
	for(int i = 0; i < x + y; i++)
		res+=t[i];
	cout << res << "\n";
}
int main(){
	#ifndef ONLINE_JUDGE	
		freopen("in.txt","r",stdin);
		freopen("out.txt","w",stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL),cout.tie(NULL);		
	int t = 1;
	//cin >> t;
	while(t--)
		solve();
	return 0;
}

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

int isAscending(int *a, int n){
  for (int i=0; i<n-1; i++){
//    cout << a[i] << " "; 
    if (a[i]>a[i+1]) return 0;
  }
  return 1;
}

int main(void){
  int n, p[100];
  int flg;
  
  cin >> n;
  for (int i=0; i<n; i++) cin >> p[i];
  flg = isAscending(p, n);
  for (int i=0; i<n; i++){
    for (int j=i+1; j<n; j++){
      int t;
      t = p[i]; p[i]=p[j]; p[j]=t;
      flg |= isAscending(p, n);// cout << endl;
      t = p[i]; p[i]=p[j]; p[j]=t;
    }
  }
  cout << (flg?"YES":"NO") << endl;
  return 0;
}
  

Measured memory_bytes: 256
m = gets.chomp.to_i
n = gets.chomp.to_i

$g = {}

n.times do
  a, b = gets.chomp.split(' ').map(&:to_i)

  $g[a] ||= []
  $g[a] << b
end

$all = (1..m).to_a
$none_order = $all - $g.values.flatten

$res = []
until $none_order.empty?
  point = $none_order.pop

  $res << point

  next unless $g[point]
  $g[point].each do |p|
    $none_order << p unless $g.any? { |s, t| s != point && t.include?(p) }
  end
  $g.delete(point)
end

puts $res



Measured memory_bytes: 6880
#include <stdio.h>
int main()
{
    int W,H,x,y,r ;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    if (0<=x-r && x+r<=W &&0<=y-r &&y+r<=H)
        puts("Yes");
    else
        puts("No");
    return 0;
}


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

const int INF = 1 << 30;
const int dx[2][6] = { {0, -1, -1, -1, 0, 1}, {1, 0, -1, 0, 1, 1} };
const int dy[6] = {-1, -1, 0, 1, 1, 0};

class State
{
public:
  int x, y, c;
  State(int _x = 0, int _y = 0, int _c = 0)
    :x(_x), y(_y), c(_c) {}
};

int main()
{
  int m, n;
  while (cin >> m >> n) {
    if ((m|n) == 0)
      break;

    int s;
    cin >> s;
    vector<vector<int> > cost(n, vector<int>(m, INF));
    for (int i = 0; i < s; ++i) {
      int x, y;
      cin >> x >> y;
      queue<State> que;
      que.push(State(x-1, y-1, 0));
      while (!que.empty()) {
	const State st = que.front();
	que.pop();

	if (cost[st.y][st.x] < st.c)
	  continue;

	cost[st.y][st.x] = st.c;
	for (int d = 0; d < 6; ++d) {
	  x = st.x + dx[st.y%2][d];
	  y = st.y + dy[d];
	  if (x < 0 || m <= x || y < 0 || n <= y || cost[y][x] <= st.c+1)
	    continue;
	  cost[y][x] = st.c+1;
	  que.push(State(x, y, st.c+1));
	}
      }
    }

    int t;
    cin >> t;
    int ans = 0;
    for (int i = 0; i < t; ++i) {
      int x, y, cnt = 0;
      cin >> x >> y;
      queue<State> que;
      que.push(State(x-1, y-1, 0));
      vector<vector<int> > visited(n, vector<int>(m, 0));
      while (!que.empty()) {
	const State st = que.front();
	que.pop();

	if (cost[st.y][st.x] <= st.c || visited[st.y][st.x])
	  continue;

	++cnt;
	visited[st.y][st.x] = 1;
	for (int d = 0; d < 6; ++d) {
	  x = st.x + dx[st.y%2][d];
	  y = st.y + dy[d];
	  if (x < 0 || m <= x || y < 0 || n <= y || cost[y][x] <= st.c+1 || visited[y][x])
	    continue;
	  que.push(State(x, y, st.c+1));
	}
      }
      ans = max(ans, cnt);
    }

    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 0
N = int(input())
#ある頂点がLRに存在する個数とある辺がLRに存在する範囲を求める

ans = 0
for i in range(1,N+1):
    ans += i*(N-i+1) #頂点数*（その頂点数が何個作れるか）
for i in range(N-1):
    u,v = map(int,input().split())
    ans -= min(u,v)*(N+1-max(u,v)) #辺がLRに含まれる個数
print(ans)

Measured memory_bytes: 74360
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class ABC
	{
		static void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			int n = int.Parse(Console.ReadLine());
			int[] d = Console.ReadLine().Split().Select(int.Parse).ToArray();
			int ans = 0;
			for (int i = 0; i < n - 1; i++) {
				for (int j = i + 1; j < n; j++) {
					ans += d[i] * d[j];
					// System.Diagnostics.Debug.WriteLine($"{i} * {j} = {d[i] * d[j]}");
				}
			}
			Console.WriteLine(ans);


			Console.Out.Flush();
		}
	}
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
 
using namespace std;
 
vector<int> dp;
vector<vector<int>> from;
 
int dfs(int v) {
    if(dp.at(v) != -1) return dp.at(v);

    int ret = -1;

    for(int vf: from.at(v)) ret = max(ret, dfs(vf));
    return dp.at(v) = ret + 1;
}
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
 
    int n, m;
 
    cin >> n >> m;
 
    int x, y;
    vector<bool> head(n + 1, true);
 
    from = vector<vector<int>>(n + 1);
 
    for(int i = 0; i < m; ++i) {
        cin >> x >> y;
        from.at(y).emplace_back(x);
        head.at(x) = false;
    }
 
    dp = vector<int>(n + 1, -1);
 
    int ans = 0;
 
    for(int i = 1; i <= n; ++i) if(head.at(i)) ans = max(ans, dfs(i));
 
    printf("%d\n", ans);
 
    return 0;
}

Measured memory_bytes: 10880
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <string.h>
#include <math.h>

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

using namespace std;

typedef long long ll;

ll n, x;
ll d[101];

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

    d[0] = 0;
    ll l;
    REP(i, n) {
        cin >> l;
        d[i + 1] = d[i] + l;
    }
    
    ll count = 0;
    REP(i, n + 1) {
        if (d[i] <= x) {
            count++;
        }
    }
    
    cout << count << endl;
    return 0;
}



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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  sort(a.begin(), a.end());

  unordered_map<int, int> mp;
  rep(i, n) {
    if (mp.count(a[i]))
      mp[a[i]]++;
    else
      mp[a[i]] = 1;
  }

  vector<bool> found(1e6 + 1, false);
  int ans = 0;

  rep(i, n) {
    if (found[a[i]]) continue;

    if (mp[a[i]] == 1) ans++;
    int k = a[i];
    while (k <= 1e6 + 1) {
      found[k] = true;
      k += a[i];
    }
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 12364
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics;
using System.Dynamic;
using System.Linq;
using System.Numerics;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;

namespace atcorder
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            int D = intArray[0];
            int T = intArray[1];
            int S = intArray[2];
            if(D <= T * S)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    } 
}


//文字配列の取得
//string[] strArray = Console.ReadLine().Split(' ').ToArray();
//string S = strArray[0];
//string T = strArray[1];

//文字列の取得
//string s = Console.ReadLine();

//数字配列の取得
//int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
//int H = intArray[0];
//int W = intArray[1];

//数字の取得
//int N = int.Parse(Console.ReadLine());

//リスト型(int)の取得
//List<int> A = new List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray());

//出力
//Console.WriteLine(ans);
//Console.WriteLine("Yes");
//Console.WriteLine("No");
//Console.WriteLine(cnt);



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

namespace std {
template <>
struct hash<pair<int, int>> {
  size_t operator()(const pair<int, int>& v) const noexcept {
    return hash<int>()(v.first << 16 ^ v.second);
  }
};
}  // namespace std

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int H, W;
  cin >> H >> W;
  vector<string> S(H);
  rep(i, H) cin >> S[i];
  unordered_map<pair<int, int>, int> s;
  queue<pair<int, int>> q;
  int ans = 0;
  rep(sy, H) rep(sx, W) {
    if (S[sy][sx] != '.') continue;
    s.clear();
    auto p = make_pair(sx, sy);
    s[p] = 1;
    q.push(p);
    int d;
    while (!q.empty()) {
      p = q.front();
      q.pop();
      d = s[p];
      rep(i, 4) {
        int x = p.first + dxy[i], y = p.second + dxy[i + 1];
        auto np = make_pair(x, y);
        if (x < 0 || x >= W || y < 0 || y >= H || S[y][x] != '.' || s[np])
          continue;
        s[np] = d + 1;
        q.push(np);
      }
    }
    ans = max(ans, d - 1);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
N=int(input())
Ai = list(map(int, input().split()))
student_numbers = [i+1 for i in range(N)]
Ai_n_stu_num = list(zip(Ai, student_numbers))
Ai_n_stu_num.sort(key = lambda x:x[0])
i = 0
while (i < N):
    print(Ai_n_stu_num[i][1], end=" ")
    i+=1

Measured memory_bytes: 20232
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<deque>
#include<cstdio>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N = 1000000;
const int mod = 998244353;
const ll INF = 1LL << 60;
#define rep(i,n) for(ll i=(ll)0;i<(ll)n;++i)
#define ALL(x) x.begin(),x.end()
#define pp pair<ll,ll>
#define fi first
#define se second
#define pb push_back
#define fix(n) fixed<<setprecision(n)
#define itr vector<ll>::iterator
struct edge { ll to, cost; };
typedef pair<ll, ll> PP;
// ↑costと頂点番号のペア
vector<edge> lists[100010],lists2[100010];
ll d[100010],d2[100010];
ll n, m, s, g;
void DIJX(ll st) {
	rep(i, n)d[i] = INF; // std::fillでも書ける
	d[st] = 0; // 始点
	priority_queue<PP, vector<PP>, greater<PP>> pq;
	pq.push(make_pair(d[st], st)); // (cost,頂点番号)
	while (!pq.empty()) {
		PP p = pq.top();
		pq.pop();
		ll i = p.second; // costがfirst、頂点番号がsecond
		if (d[i]<p.first)continue;
		rep(k, lists[i].size()) {
			edge e = lists[i][k];
			if (d[e.to] <= d[i] + e.cost)continue;
			d[e.to] = d[i] + e.cost;
			pq.push(std::make_pair(d[e.to], e.to));
		}
	}
}
void DIJX2(ll st) {
	rep(i, n)d2[i] = INF; // std::fillでも書ける
	d2[st] = 0; // 始点
	priority_queue<PP, vector<PP>, greater<PP>> pq;
	pq.push(make_pair(d2[st], st)); // (cost,頂点番号)
	while (!pq.empty()) {
		PP p = pq.top();
		pq.pop();
		ll i = p.second; // costがfirst、頂点番号がsecond
		if (d2[i]<p.first)continue;
		rep(k, lists2[i].size()) {
			edge e = lists2[i][k];
			if (d2[e.to] <= d2[i] + e.cost)continue;
			d2[e.to] = d2[i] + e.cost;
			pq.push(std::make_pair(d2[e.to], e.to));
		}
	}
}
int main() {
	cin >> n >> m >> s >> g; --s; --g;
	ll a,aa,b,bb;
	rep(i, m) {
		cin >> a >> b >> aa >> bb; --a, --b;
		lists[a].pb(edge{ b,aa });
		lists[b].pb(edge{ a,aa });
		lists2[a].pb(edge{ b,bb });
		lists2[b].pb(edge{ a,bb });
	}
	DIJX(s); DIJX2(g);
	ll ans[100010];
	for (ll i = n - 1; i >= 0; --i) {
		if (i == n - 1)ans[i] = d[i]+d2[i];
		else {
			ans[i] = min(ans[i + 1], d[i] + d2[i]);
		}
	}
	rep(i, n)cout <<(ll)pow(10, 15) - ans[i] << endl;
	return 0;
}

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

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

int main()
{
    int n, l;
    cin >> n >> l;
    vector<string> a;
    rep(i, n)
    {
        string temp;
        cin >> temp;
        a.push_back(temp);
    }
    SORT(a);
    rep(i,n){
        cout<<a[i];
    }
    cout<<endl;
    return 0;
}

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

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

int n,m;
vector<int> d[101];

int main(void){
	while(1){
		scanf("%d%d",&n,&m);
		if(n==0 && m==0)break;
		for(int i=0;i<=m;i++){
			d[i].clear();
		}
		for(int i=0;i<n;i++){
			int dd;
			int vv;
			scanf("%d%d",&dd,&vv);
			d[dd].push_back(vv);
		}
		for(int i=1;i<=m;i++){
			sort(d[i].begin(),d[i].end());
			reverse(d[i].begin(),d[i].end());
		}
		int res=0;
		for(int i=1;i<=m;i++){
			if(d[i].size()==0)continue;
			res+=d[i][0];
		}
		printf("%d\n",res);

	}
	return 0;
}

Measured memory_bytes: 3152
N,M = map(int,input().split())
H = list(map(int,input().split()))
high = [1] * N

for i in range(M):
  A,B = map(int,input().split())
  if H[A-1] < H[B-1]:
    high[A-1] = 0
  elif H[A-1] > H[B-1]:
    high[B-1] = 0
  else:
    high[A-1] = 0
    high[B-1] = 0

print(sum(high))

Measured memory_bytes: 19980
#include<bits/stdc++.h>
#include<vector>
#define N 400005
using namespace std;
vector<int> G[N];
int n,m=1,a[N],b[N],head[N],nxt[N],num[N],vis[N],op[N],dex[N],X[N],rt,cnt;
void link(int x,int y,int z) {
	num[++m]=y,dex[m]=z,nxt[m]=head[x],head[x]=m;
	num[++m]=x,dex[m]=z,nxt[m]=head[y],head[y]=m;
}
void dfs(int t)
{
	int i;
	while (i=head[t]) {
		head[t]=nxt[i];
		if (vis[i]||vis[i^1]) continue;		
		if (++cnt==1000000) {
			printf("F**K");
			exit(0);
		}
		vis[i]=vis[i^1]=1;
		dfs(num[i]);
		if (~dex[i]&1)
			X[dex[i]/2]=(i&1 ? 1 : -1);
	}
}
void DFS(int t)
{
	int i;
	for(i=0;i<G[t].size();i++)
		X[t]-=X[G[t][i]],DFS(G[t][i]);
}
int main()
{
	int i;
	scanf("%d",&n);
	for (i=1;i<=n;i++) scanf("%d",&a[i]);
	for (i=1;i<=n;i++) scanf("%d",&b[i]);
	for (i=1;i<=n;i++) {
		if (a[i]!=-1) G[a[i]].push_back(i); else rt=i;
		link(i,(a[i]==-1 ? n+1 : a[i]),2*i);
		link((b[i]==-1 ? n+1 : b[i]),i,2*i+1);
		if (a[i]>0) op[a[i]]^=1;
		if (b[i]>0) op[b[i]]^=1;
	}
	for (i=1;i<=n;i++)
		if (op[i]) {
			printf("IMPOSSIBLE");
			return 0;
		}
 	dfs(n+1);
	DFS(rt);
	printf("POSSIBLE\n");
	for (i=1;i<=n;i++)
		printf("%d ",X[i]);
	return 0;
}


Measured memory_bytes: 30464
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <climits>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
using namespace std;
#define ll long long 
#define pb push_back
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
//typedef long long  MOD=1000000009;
ll MOD=998244353;
ll add(ll x, ll y) {ll res = x + y; return (res >= MOD ? res - MOD : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= MOD ? res % MOD : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + MOD : res);}
ll lcm(ll x, ll y) {ll res = (x * y) / __gcd(x, y); return res;}
ll power(ll x, ll y) {if (y < 0) return 1; ll res = 1; x %= MOD; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}

void iofoj(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}


void solution()
{
    ll k,i,j,h,n,m,w;
   string s;
   cin>>s;
   ll sum=0;
   for(i=0;i<s.length();i++)
   {
       sum+=s[i]-'0';
   }
   if(sum%9==0)
   cout<<"Yes";
   else 
   cout<<"No";
}

int main(){
    fio
    //iofoj();
    // ll t;
    // cin>>t;
    // while(t--)
    solution();
    return 0; 
}





Measured memory_bytes: 3784
from collections import defaultdict
def solve():
  H, W, M = map(int, input().split())
  bomb = defaultdict(lambda: 0)
  lis_h = [0]*H
  lis_w = [0]*W
  for _ in range(M):
    h,w = map(int, input().split())
    h -= 1
    w -= 1
    bomb[(h,w)] = 1
    lis_h[h] += 1
    lis_w[w] += 1
  m_h = max(lis_h)
  m_w = max(lis_w)
  m_h_lis = []
  m_w_lis = []
  for i in range(H):
    if lis_h[i]==m_h:
      m_h_lis.append(i)
  for i in range(W):
    if lis_w[i]==m_w:
      m_w_lis.append(i)
  ans = 0
  for h in m_h_lis:
    for w in m_w_lis:
      if bomb[(h,w)]==0:
        return m_h+m_w
  return m_h+m_w-1
print(solve())


Measured memory_bytes: 85732